paperlint 16.8.0 → 17.1.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/CLAUDE.md +10 -2
- package/CONTRIBUTING.md +1 -1
- package/README.md +17 -14
- package/dist/adapters/latex/abstract.d.ts +7 -1
- package/dist/adapters/latex/abstract.d.ts.map +1 -1
- package/dist/adapters/latex/abstract.js +19 -4
- package/dist/adapters/latex/abstract.js.map +1 -1
- package/dist/adapters/latex/captions.d.ts +6 -5
- package/dist/adapters/latex/captions.d.ts.map +1 -1
- package/dist/adapters/latex/captions.js +14 -30
- package/dist/adapters/latex/captions.js.map +1 -1
- package/dist/adapters/latex/index.d.ts +1 -1
- package/dist/adapters/latex/index.d.ts.map +1 -1
- package/dist/adapters/latex/index.js +5 -2
- package/dist/adapters/latex/index.js.map +1 -1
- package/dist/adapters/latex/prose.d.ts +6 -0
- package/dist/adapters/latex/prose.d.ts.map +1 -1
- package/dist/adapters/latex/prose.js +18 -12
- package/dist/adapters/latex/prose.js.map +1 -1
- package/dist/cli.d.ts +6 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +16 -8
- package/dist/cli.js.map +1 -1
- package/dist/domain/register.d.ts +23 -1
- package/dist/domain/register.d.ts.map +1 -1
- package/dist/domain/register.js +37 -14
- package/dist/domain/register.js.map +1 -1
- package/dist/domain/term-definitions.d.ts +48 -0
- package/dist/domain/term-definitions.d.ts.map +1 -0
- package/dist/domain/term-definitions.js +228 -0
- package/dist/domain/term-definitions.js.map +1 -0
- package/dist/domain/tex-document.d.ts +11 -0
- package/dist/domain/tex-document.d.ts.map +1 -1
- package/dist/domain/tex-document.js.map +1 -1
- package/dist/eslint-rules/review-frontmatter.js +5 -5
- package/dist/eslint-rules/review-frontmatter.schema.json +15 -8
- package/dist/eslint-rules/sibling-frontmatter.d.ts.map +1 -1
- package/dist/folder-venue-rule.d.ts +1 -1
- package/dist/folder-venue-rule.d.ts.map +1 -1
- package/dist/folder-venue-rule.js +4 -2
- package/dist/folder-venue-rule.js.map +1 -1
- package/dist/hooks-notice.d.ts +3 -3
- package/dist/hooks-notice.d.ts.map +1 -1
- package/dist/hooks-notice.js +41 -8
- package/dist/hooks-notice.js.map +1 -1
- package/dist/link-skills.d.ts +5 -0
- package/dist/link-skills.d.ts.map +1 -1
- package/dist/link-skills.js +7 -0
- package/dist/link-skills.js.map +1 -1
- package/dist/ports/latex.d.ts +11 -1
- package/dist/ports/latex.d.ts.map +1 -1
- package/dist/presets.d.ts +21 -2
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +66 -17
- package/dist/presets.js.map +1 -1
- package/dist/readability.d.ts +12 -2
- package/dist/readability.d.ts.map +1 -1
- package/dist/readability.js +76 -3
- package/dist/readability.js.map +1 -1
- package/dist/register-bands.d.ts +16 -5
- package/dist/register-bands.d.ts.map +1 -1
- package/dist/register-bands.js +56 -17
- package/dist/register-bands.js.map +1 -1
- package/dist/skills/argument-arc/scripts/headings-core.d.ts +12 -0
- package/dist/skills/argument-arc/scripts/headings.d.ts +2 -0
- package/dist/skills/cold-read-diff/scripts/cold-read-core.d.ts +12 -0
- package/dist/skills/cold-read-diff/scripts/readers.d.ts +2 -1
- package/dist/term-definition-rules.d.ts +26 -0
- package/dist/term-definition-rules.d.ts.map +1 -0
- package/dist/term-definition-rules.js +137 -0
- package/dist/term-definition-rules.js.map +1 -0
- package/dist/tex-paper.d.ts +6 -0
- package/dist/tex-paper.d.ts.map +1 -1
- package/dist/tex-paper.js +10 -0
- package/dist/tex-paper.js.map +1 -1
- package/dist/tex-requirements.d.ts +2 -0
- package/dist/tex-requirements.d.ts.map +1 -1
- package/dist/tex-requirements.js +9 -0
- package/dist/tex-requirements.js.map +1 -1
- package/dist/tex-venue-rules.d.ts +3 -2
- package/dist/tex-venue-rules.d.ts.map +1 -1
- package/dist/tex-venue-rules.js +3 -2
- package/dist/tex-venue-rules.js.map +1 -1
- package/docs/configuration.md +2 -2
- package/{skills/paper-pipeline/references → docs/design}/acceptance-gate.md +50 -53
- package/docs/design/paper-pipeline-history.md +217 -0
- package/docs/design/skill-provenance.md +132 -0
- package/docs/design/study-modes.md +1 -1
- package/docs/design/verify-citations-history.md +135 -0
- package/docs/design/writing-exemplars.md +19 -0
- package/docs/install.md +7 -4
- package/docs/layout.md +5 -4
- package/docs/optional-rules.md +4 -0
- package/docs/osf-artifact.md +54 -0
- package/docs/pipeline.md +171 -0
- package/docs/render.md +82 -0
- package/docs/rules/paper/folder-venue-leftover.md +10 -7
- package/docs/rules/tex/contrast-frames.md +1 -2
- package/docs/rules/tex/max-caption-words.md +82 -0
- package/docs/rules/tex/max-paragraph-words.md +2 -2
- package/docs/rules/tex/negated-sentences.md +96 -0
- package/docs/rules/tex/term-before-definition.md +103 -0
- package/docs/rules/tex/term-defined-twice.md +62 -0
- package/docs/rules/tex/venue-leftover.md +13 -1
- package/docs/rules.md +23 -18
- package/docs/skills.md +16 -21
- package/docs/submission.md +14 -0
- package/docs/texlive-install-decision.md +1 -1
- package/docs/toolchain.md +11 -11
- package/eslint-rules/review-frontmatter.schema.json +15 -8
- package/eslint-rules/review-frontmatter.test.mjs +8 -5
- package/eslint-rules/review-frontmatter.ts +5 -5
- package/eslint.config.mjs +1 -5
- package/hooks/paper-status-gates.sh +21 -4
- package/hooks/paper-status-gates.test.ts +51 -0
- package/lib/skill-checks.test.mjs +2 -6
- package/lib/skill-trigger-cases.mjs +12 -97
- package/lib/skill-trigger-cases.test.ts +0 -6
- package/package.json +3 -1
- package/presets/acm-sigconf.md +1 -1
- package/presets/agenticdev.jsonc +5 -2
- package/presets/agenticdev.md +4 -2
- package/presets/aidc.jsonc +14 -1
- package/presets/aidc.md +3 -2
- package/presets/aisec.jsonc +9 -3
- package/presets/aisec.md +4 -1
- package/presets/ase.jsonc +145 -0
- package/presets/ase.md +178 -0
- package/presets/ccs.jsonc +87 -0
- package/presets/ccs.md +184 -0
- package/presets/icse.jsonc +100 -0
- package/presets/icse.md +126 -0
- package/presets/ieee-conference.md +1 -1
- package/presets/sp.jsonc +152 -0
- package/presets/sp.md +160 -0
- package/presets/venue-profile.schema.json +22 -3
- package/scripts/harness-api.frozen.json +0 -4
- package/scripts/pipeline.ts +481 -0
- package/skills/CLAUDE.md +2 -2
- package/skills/CLAUDE.md.spec.ts +26 -1
- package/skills/analyze-sibling-paper/SKILL.md +2 -20
- package/skills/analyze-sibling-paper/SKILL.md.spec.ts +9 -19
- package/skills/argument-arc/SKILL.md +32 -18
- package/skills/argument-arc/SKILL.md.spec.ts +43 -17
- package/skills/argument-arc/scripts/headings-core.js +46 -0
- package/skills/argument-arc/scripts/headings-core.ts +65 -0
- package/skills/argument-arc/scripts/headings.js +15 -0
- package/skills/argument-arc/scripts/headings.test.ts +105 -0
- package/skills/argument-arc/scripts/headings.ts +20 -0
- package/skills/build-benchmark/SKILL.md +1 -12
- package/skills/build-benchmark/SKILL.md.spec.ts +15 -11
- package/skills/build-label-page/SKILL.md.spec.ts +11 -0
- package/skills/camera-ready/SKILL.md +1 -8
- package/skills/camera-ready/SKILL.md.spec.ts +8 -7
- package/skills/cold-read-diff/SKILL.md +36 -25
- package/skills/cold-read-diff/SKILL.md.spec.ts +44 -24
- package/skills/cold-read-diff/scripts/cold-read-core.js +63 -6
- package/skills/cold-read-diff/scripts/cold-read-core.ts +81 -6
- package/skills/cold-read-diff/scripts/cold-read.js +1 -1
- package/skills/cold-read-diff/scripts/cold-read.test.ts +66 -0
- package/skills/cold-read-diff/scripts/cold-read.ts +1 -1
- package/skills/cold-read-diff/scripts/readers.js +2 -1
- package/skills/cold-read-diff/scripts/readers.ts +2 -1
- package/skills/draft-paper/SKILL.md +16 -29
- package/skills/draft-paper/SKILL.md.spec.ts +27 -28
- package/skills/extend-paper/SKILL.md +7 -16
- package/skills/extend-paper/SKILL.md.spec.ts +18 -15
- package/skills/find-venue/SKILL.md +11 -24
- package/skills/find-venue/SKILL.md.spec.ts +19 -23
- package/skills/harden-paper/SKILL.md +62 -290
- package/skills/harden-paper/SKILL.md.spec.ts +82 -304
- package/skills/harden-paper/harden-paper.harness.mjs +1 -2
- package/skills/jobs.ts +25 -0
- package/skills/label-agent-runs/SKILL.md.spec.ts +10 -0
- package/skills/map-prior-work/SKILL.md +5 -4
- package/skills/map-prior-work/SKILL.md.spec.ts +13 -3
- package/skills/paper-pipeline/SKILL.md +80 -278
- package/skills/paper-pipeline/SKILL.md.spec.ts +130 -276
- package/skills/paper-pipeline/description-language.eval.mjs +0 -22
- package/skills/paper-pipeline/framing-vs-vocabulary.eval.mjs +0 -29
- package/skills/paper-pipeline/paper-pipeline.harness.mjs +0 -16
- package/skills/paper-pipeline/pipeline-firing.eval.mjs +7 -29
- package/skills/paper-pipeline/pipeline-language.eval.mjs +0 -52
- package/skills/paper-pipeline/references/artifact-checklist.md +6 -1
- package/skills/paper-pipeline/references/body-vs-appendix.md +3 -4
- package/skills/paper-pipeline/references/pipeline-status-template.md +8 -10
- package/skills/paper-pipeline/references/review-ratchet.md +4 -7
- package/skills/paper-pipeline/references/venue-bar.md +1 -2
- package/skills/paper-pipeline/references/writing-craft.md +21 -281
- package/skills/paper-status/SKILL.md +17 -20
- package/skills/paper-status/SKILL.md.spec.ts +23 -19
- package/skills/pc-panel-review/SKILL.md +66 -93
- package/skills/pc-panel-review/SKILL.md.spec.ts +75 -92
- package/skills/plan-paper-timeline/SKILL.md +7 -29
- package/skills/plan-paper-timeline/SKILL.md.spec.ts +16 -28
- package/skills/plan-paper-timeline/plan-paper-timeline.effects.harness.mjs +2 -2
- package/skills/render-paper/check-render.sh +2 -2
- package/skills/render-paper/render-paper.harness.mjs +4 -20
- package/skills/research-ideate/SKILL.md +15 -32
- package/skills/research-ideate/SKILL.md.spec.ts +25 -31
- package/skills/rewrite-unclear/SKILL.md +15 -14
- package/skills/rewrite-unclear/SKILL.md.spec.ts +24 -15
- package/skills/rewrite-unclear/rewrite-unclear.eval.ts +2 -3
- package/skills/run-agent-grid/SKILL.md +3 -3
- package/skills/run-agent-grid/SKILL.md.spec.ts +10 -2
- package/skills/study-accepted-papers/SKILL.md +5 -5
- package/skills/study-accepted-papers/SKILL.md.spec.ts +27 -4
- package/skills/submit-paper/SKILL.md +37 -31
- package/skills/submit-paper/SKILL.md.spec.ts +46 -30
- package/skills/submit-paper/check-deanon.sh +1 -1
- package/skills/tighten-paper/SKILL.md +43 -68
- package/skills/tighten-paper/SKILL.md.spec.ts +51 -67
- package/skills/verify-citations/SKILL.md +18 -112
- package/skills/verify-citations/SKILL.md.spec.ts +27 -114
- package/src/adapters/latex/abstract.test.ts +42 -0
- package/src/adapters/latex/abstract.ts +23 -6
- package/src/adapters/latex/captions.test.ts +36 -38
- package/src/adapters/latex/captions.ts +16 -33
- package/src/adapters/latex/index.test.ts +11 -0
- package/src/adapters/latex/index.ts +5 -2
- package/src/adapters/latex/prose.ts +23 -11
- package/src/cli.ts +26 -5
- package/src/domain/register.test.ts +65 -0
- package/src/domain/register.ts +72 -16
- package/src/domain/term-definitions.test.ts +240 -0
- package/src/domain/term-definitions.ts +329 -0
- package/src/domain/tex-document.ts +12 -0
- package/src/domain/venue-name.test.ts +4 -4
- package/src/folder-venue-rule.test.ts +23 -2
- package/src/folder-venue-rule.ts +8 -8
- package/src/hooks-notice.test.ts +127 -0
- package/src/hooks-notice.ts +50 -10
- package/src/link-skills.ts +9 -0
- package/src/new-paper.test.ts +2 -2
- package/src/paper-settings-commands.test.ts +1 -1
- package/src/ports/latex.ts +11 -0
- package/src/preset-card-rule.test.ts +4 -0
- package/src/presets.test.ts +141 -4
- package/src/presets.ts +113 -22
- package/src/readability.test.ts +92 -0
- package/src/readability.ts +113 -5
- package/src/register-bands.test.ts +81 -1
- package/src/register-bands.ts +88 -23
- package/src/rule-cases.test.ts +122 -2
- package/src/term-definition-rules.test.ts +150 -0
- package/src/term-definition-rules.ts +189 -0
- package/src/tex-paper.test.ts +18 -1
- package/src/tex-paper.ts +11 -0
- package/src/tex-requirements.ts +15 -0
- package/src/tex-venue-rules.test.ts +45 -1
- package/src/tex-venue-rules.ts +8 -3
- package/src/venue-rules.test.ts +2 -2
- package/templates/paper/PIPELINE-STATUS.md +19 -19
- package/dist/paper-prose.d.ts +0 -17
- package/dist/paper-prose.d.ts.map +0 -1
- package/dist/paper-prose.js +0 -46
- package/dist/paper-prose.js.map +0 -1
- package/skills/grade-paper-writing/SKILL.md +0 -494
- package/skills/grade-paper-writing/SKILL.md.spec.ts +0 -501
- package/skills/grade-paper-writing/__snapshots__/prose-lint.test.ts.snap +0 -84
- package/skills/grade-paper-writing/fixtures/control_gopen.txt +0 -1
- package/skills/grade-paper-writing/fixtures/control_human_paper.txt +0 -1
- package/skills/grade-paper-writing/fixtures/rewrite.txt +0 -1
- package/skills/grade-paper-writing/fixtures/specimen.txt +0 -1
- package/skills/grade-paper-writing/fixtures/structure-checks.md +0 -22
- package/skills/grade-paper-writing/grade-paper-writing.eval.mjs +0 -19
- package/skills/grade-paper-writing/grade-paper-writing.harness.mjs +0 -23
- package/skills/grade-paper-writing/prose-lint.mjs +0 -602
- package/skills/grade-paper-writing/prose-lint.test.ts +0 -413
- package/skills/osf-artifact-upload/SKILL.md +0 -58
- package/skills/osf-artifact-upload/SKILL.md.spec.ts +0 -65
- package/skills/osf-artifact-upload/osf-artifact-upload.eval.mjs +0 -22
- package/skills/osf-artifact-upload/osf-artifact-upload.harness.ts +0 -102
- package/skills/paper-adversarial-review/SKILL.md +0 -100
- package/skills/paper-adversarial-review/SKILL.md.spec.ts +0 -107
- package/skills/paper-adversarial-review/paper-adversarial-review.eval.mjs +0 -19
- package/skills/paper-adversarial-review/paper-adversarial-review.harness.mjs +0 -24
- package/skills/paper-pipeline/grade-paper-writing-ablation.eval.mjs +0 -1274
- package/skills/paper-pipeline/references/credit-criteria.md +0 -69
- package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/README.md +0 -35
- package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/run_retext.mjs +0 -24
- package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/sentences.txt +0 -11
- package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/test_sentences.py +0 -25
- package/skills/paper-pipeline/references/occupancy-2026-08-06-prose-checkers.md +0 -538
- package/skills/paper-pipeline/references/occupancy-2026-08-06-reproducible-tooling.md +0 -431
- package/skills/paper-pipeline/references/occupancy-2026-08-06-staleness-and-orchestration.md +0 -592
- package/skills/paper-pipeline/repro/2026-08-08-parent-replication.mjs +0 -92
- package/skills/render-paper/SKILL.md +0 -123
- package/skills/render-paper/SKILL.md.spec.ts +0 -130
- package/skills/render-paper/render-paper.eval.mjs +0 -19
- package/skills/submission-portal/SKILL.md +0 -129
- package/skills/submission-portal/SKILL.md.spec.ts +0 -134
- package/skills/submission-portal/submission-portal.eval.mjs +0 -15
- package/skills/submission-portal/submission-portal.test.ts +0 -12
- package/skills/sweep-design-space/SKILL.md +0 -232
- package/skills/sweep-design-space/SKILL.md.spec.ts +0 -248
- package/skills/sweep-design-space/sweep-design-space.eval.mjs +0 -19
- package/skills/sweep-design-space/sweep-design-space.harness.mjs +0 -23
- package/src/paper-prose.test.ts +0 -78
- package/src/paper-prose.ts +0 -67
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Fixture — planted defects for the two paragraph-level checks"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
## Abstract
|
|
6
|
-
|
|
7
|
-
Clean prose with nothing planted in it at all.
|
|
8
|
-
|
|
9
|
-
## 1. Introduction
|
|
10
|
-
|
|
11
|
-
PLANT-A: this paragraph stops the reader at five separate citation sites, which is above the
|
|
12
|
-
threshold [1], and the rest of it says very little [2] while continuing to cite things [3] and
|
|
13
|
-
then some more things [4] and finally one more [5, 6]. Note that the last site holds two numbers
|
|
14
|
-
and still counts once — that is the whole point of counting sites rather than numbers.
|
|
15
|
-
|
|
16
|
-
PLANT-B: watch the agent instead of the file, against a temporal logic, a policy language a
|
|
17
|
-
solver checks, or a learned model of what the repository does.
|
|
18
|
-
|
|
19
|
-
CLEAN-A: this paragraph carries one marker [7] and no unexplained vocabulary, so neither check
|
|
20
|
-
should have anything to say about it.
|
|
21
|
-
|
|
22
|
-
CLEAN-B: soundness alone in a sentence is one term, not a pile-up, and must stay quiet.
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* grade-paper-writing — the PAID tier: does this skill's description actually fire?
|
|
3
|
-
*
|
|
4
|
-
* COLOCATED ON PURPOSE (vigiles decides coverage by placement as of 2026-08-11).
|
|
5
|
-
* The prompts live in `.claude/lib/skill-trigger-cases.mjs` so all 21 cases
|
|
6
|
-
* are reviewed as one table where collisions between siblings are visible;
|
|
7
|
-
* copying them here would recreate the drift that rule exists to prevent.
|
|
8
|
-
*
|
|
9
|
-
* Measures recall (fires on its own territory) AND precision (stays quiet on a
|
|
10
|
-
* colliding sibling's territory), against the REAL `.claude` harness so the skill
|
|
11
|
-
* competes with every other installed description — an isolated run overstates
|
|
12
|
-
* recall and understates false positives.
|
|
13
|
-
*
|
|
14
|
-
* Costs money; not CI.
|
|
15
|
-
* node .claude/skills/grade-paper-writing/grade-paper-writing.eval.mjs [trials]
|
|
16
|
-
*/
|
|
17
|
-
import { runSkillTriggerEval } from "../../lib/skill-eval-kit.mjs";
|
|
18
|
-
|
|
19
|
-
await runSkillTriggerEval("grade-paper-writing");
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* grade-paper-writing — the free, deterministic tier. No model, no network.
|
|
3
|
-
*
|
|
4
|
-
* COLOCATED ON PURPOSE. vigiles decides coverage by PLACEMENT as of 2026-08-11:
|
|
5
|
-
* a test that merely names a surface no longer counts, because that tier was
|
|
6
|
-
* crediting surfaces nothing touched. So each skill needs a file inside its own
|
|
7
|
-
* directory — this one.
|
|
8
|
-
*
|
|
9
|
-
* The assertions live in `.claude/lib/skill-checks.mjs` and are CALLED here with
|
|
10
|
-
* this skill's name. They are not copied: 22 copies of the same checks is the drift that
|
|
11
|
-
* module exists to avoid. (Until 2026-08-11 this was an env-var side channel into a
|
|
12
|
-
* 614-line file named after no surface; it is a function call now.)
|
|
13
|
-
*
|
|
14
|
-
* What this proves: this skill's frontmatter parses as strict YAML, its declared
|
|
15
|
-
* tool contract is sane, its pipeline wiring points at scripts that exist, and it
|
|
16
|
-
* announces/records under ITS OWN identity rather than a sibling's.
|
|
17
|
-
*
|
|
18
|
-
* What it does NOT prove: that the skill fires, or that its guidance produces a
|
|
19
|
-
* good result. Those need a real model — see `grade-paper-writing.eval.mjs`.
|
|
20
|
-
*/
|
|
21
|
-
import { checkSkill } from "../../lib/skill-checks.mjs";
|
|
22
|
-
|
|
23
|
-
await checkSkill("grade-paper-writing");
|
|
@@ -1,602 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* prose-lint.mjs — countable checks for "reads machine-written" expository prose, on a paper's
|
|
4
|
-
* LaTeX source or on the text of its rendered PDF.
|
|
5
|
-
* Usage: node prose-lint.mjs <paper.tex|page.txt> [more files] [--flags-only|--headings]
|
|
6
|
-
*
|
|
7
|
-
* Every check counts something. Thresholds and their provenance are in THRESHOLDS.
|
|
8
|
-
*
|
|
9
|
-
* A `.tex` IS READ THROUGH THE PAPER'S PROSE, NOT AS TEXT. Read raw, a `.tex` put the preamble, the
|
|
10
|
-
* `%` comments and the `filecontents` bibliography into the word count — measured on one paper:
|
|
11
|
-
* `8127 words` against ~4636 real ones — and every metric here is a fraction of that count, so all
|
|
12
|
-
* of them came out understated by about half and printed `ok`. `paperProse` (src/paper-prose.ts)
|
|
13
|
-
* gives the body as the `tex/register` rule reads it: includes spliced, the abstract to the back
|
|
14
|
-
* matter, no headings, captions, floats, code or citation marks. The files spliced in are the ones the
|
|
15
|
-
* paper's last build recorded TeX reading (`_build/sources.json`); a paper with no current record is
|
|
16
|
-
* read as `paper.tex` alone, and the run says so on stderr rather than print rates of half a paper.
|
|
17
|
-
*
|
|
18
|
-
* A `.txt` is the text of the rendered PDF — the page a reviewer actually reads.
|
|
19
|
-
*
|
|
20
|
-
* The figure captions are measured too, in the report: every `\caption{}` in `paper.tex` and the
|
|
21
|
-
* files it includes, or, beside a rendered page, in `figures/*.tex`.
|
|
22
|
-
*
|
|
23
|
-
* Advisory: the report prints every check and exits 0. `--flags-only` prints the checks the report
|
|
24
|
-
* marks FLAG, each with the lines under it, and nothing on a clean paper; it exits 1 when there is
|
|
25
|
-
* one — the form for a hook.
|
|
26
|
-
*/
|
|
27
|
-
import { paperProse } from "#src/paper-prose";
|
|
28
|
-
import { paperRecord } from "#src/paper-record";
|
|
29
|
-
import { captionsOf, latexReader, parseLatex } from "#src/adapters/latex/index";
|
|
30
|
-
import { nodeFiles } from "#src/adapters/node/index";
|
|
31
|
-
import { sourcesCodec } from "#src/adapters/sources-record/index";
|
|
32
|
-
|
|
33
|
-
const THRESHOLDS = {
|
|
34
|
-
metadiscourseTotalPer1000: {
|
|
35
|
-
warn: 90,
|
|
36
|
-
src: "Hyland 2005 Table 5.1 total 64.9/1000; Table 7.1 totals 60.0-73.6/1000. Warn ~1.4x.",
|
|
37
|
-
},
|
|
38
|
-
firstMentionDefinites: {
|
|
39
|
-
warn: 3,
|
|
40
|
-
src: 'No published rate. Operationalises Pinker\'s curse of knowledge: "the X" on first mention presupposes shared knowledge.',
|
|
41
|
-
},
|
|
42
|
-
negatedMainClausePct: {
|
|
43
|
-
warn: 50,
|
|
44
|
-
src: 'No published rate for negation. Related: Boggia 2026 (arXiv 2607.21498) measures the "not X, but Y" family per 10,000 words; human academic abstracts 3.6, LLM 7.8 (p=0.28, n.s.).',
|
|
45
|
-
},
|
|
46
|
-
topicChainBreaksPct: {
|
|
47
|
-
warn: 75,
|
|
48
|
-
src: 'Gopen & Swan 1990 principles 3-4: "We cannot tell whose story the passage is" when the topic position changes every sentence.',
|
|
49
|
-
},
|
|
50
|
-
stressPositionWaste: {
|
|
51
|
-
warn: 0,
|
|
52
|
-
src: "Gopen & Swan 1990 principle 2: put the new information you want emphasised in the stress position. A trailing citation/cross-reference/hedge wastes it.",
|
|
53
|
-
},
|
|
54
|
-
// The HEDGES lexicon is a term in metadiscourseTotalPer1000 and in the wasted stress-position
|
|
55
|
-
// detector. Deleting it would silently understate both metrics.
|
|
56
|
-
|
|
57
|
-
contrastivePer10k: {
|
|
58
|
-
warn: 25,
|
|
59
|
-
src: 'ours. "rather than" is an ordinary connective; a pile of them is a register problem, but it is NOT the construction Boggia measured and must not borrow that baseline.',
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
// 🔴 FIGURE CAPTIONS ARE PROSE THAT NOTHING WAS READING. They sit in floats, outside the body
|
|
63
|
-
// the other metrics read, so every writing pass and every persona read was blind to them by
|
|
64
|
-
// construction. Found 2026-08-05 when a reader hit a 136-word caption
|
|
65
|
-
// containing a 54-word sentence — one word under the limit that would have blocked the same
|
|
66
|
-
// sentence had it been typed into the paper. An entire text surface, unchecked.
|
|
67
|
-
captionSentenceWords: {
|
|
68
|
-
warn: 40,
|
|
69
|
-
src: "ours, from this paper's own four captions: longest sentences 21, 31, 41 and 54 words. A caption is read in one pass with the figure, so it tolerates less than body prose, where the limit is 55.",
|
|
70
|
-
},
|
|
71
|
-
captionWords: {
|
|
72
|
-
warn: 100,
|
|
73
|
-
src: "ours, same four captions: 67, 97, 135, 148. ACL captions in the venue corpus run far shorter; past ~100 words a caption is a section that happens to sit under a picture.",
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// --- lexicons ---
|
|
78
|
-
// 🔴 FRAME_MARKERS has no threshold of its own: it is a term in `metadiscourseTotalPer1000`, and
|
|
79
|
-
// deleting it would silently understate that metric. ⚠️ AND HERE IS A KNOWN DEFECT, measured the same day and NOT fixed: the
|
|
80
|
-
// three ordinal-numeral patterns give 23 matches out of 27 on a real paper, and none of them are
|
|
81
|
-
// real, while `comes? first` is written TWICE (the second time as `come(s)? (first|before)`), so
|
|
82
|
-
// every "comes first" is counted as two. That means `metadiscourse/1000w` in the report below is
|
|
83
|
-
// OVERSTATED. Deliberately untouched: narrowing the dictionary is an edit to the BEHAVIOUR of a live
|
|
84
|
-
// metric that has no test here, and making it under the guise of a move would change a number
|
|
85
|
-
// without showing that it changed.
|
|
86
|
-
const FRAME_MARKERS = [
|
|
87
|
-
/\bcomes? first\b/gi,
|
|
88
|
-
/\bfirst(ly)?\b(?=[ ,])/gi,
|
|
89
|
-
/\bsecond(ly)?\b(?=[ ,])/gi,
|
|
90
|
-
/\bthird(ly)?\b(?=[ ,])/gi,
|
|
91
|
-
/\bfinally\b/gi,
|
|
92
|
-
/\bto (conclude|summari[sz]e|begin( with)?|start)\b/gi,
|
|
93
|
-
/\bin (conclusion|summary|what follows|this (paper|section|article))\b/gi,
|
|
94
|
-
/\bwe (begin|start|turn|now turn|conclude|proceed)\b/gi,
|
|
95
|
-
/\b(my|our) (purpose|aim|goal) is\b/gi,
|
|
96
|
-
/\bthe (rest|remainder) of (this|the)\b/gi,
|
|
97
|
-
/\bbefore (we|turning|proceeding)\b/gi,
|
|
98
|
-
/\bhere we (show|present|report|argue)\b/gi,
|
|
99
|
-
/\bwe (report|present) (it|them|this) as\b/gi,
|
|
100
|
-
/\bcome(s)? (first|before)\b/gi,
|
|
101
|
-
/\bthis (paper|section) (is organi[sz]ed|proceeds)\b/gi,
|
|
102
|
-
/\bwhat follows\b/gi,
|
|
103
|
-
/\bthe (first|second|two|three) (finding|result|point|thing)s?\b/gi,
|
|
104
|
-
];
|
|
105
|
-
const TRANSITIONS = [
|
|
106
|
-
/\bhowever\b/gi,
|
|
107
|
-
/\bmoreover\b/gi,
|
|
108
|
-
/\bfurthermore\b/gi,
|
|
109
|
-
/\btherefore\b/gi,
|
|
110
|
-
/\bthus\b/gi,
|
|
111
|
-
/\bhence\b/gi,
|
|
112
|
-
/\bin addition\b/gi,
|
|
113
|
-
/\bnevertheless\b/gi,
|
|
114
|
-
/\bconsequently\b/gi,
|
|
115
|
-
/\bwhile\b/gi,
|
|
116
|
-
/\bwhereas\b/gi,
|
|
117
|
-
/\balthough\b/gi,
|
|
118
|
-
/\bthough\b/gi,
|
|
119
|
-
/\bbut\b/gi,
|
|
120
|
-
/\bso\b/gi,
|
|
121
|
-
/\byet\b/gi,
|
|
122
|
-
/\beither\b/gi,
|
|
123
|
-
/\bas well as\b/gi,
|
|
124
|
-
/\bin contrast\b/gi,
|
|
125
|
-
/\bon the other hand\b/gi,
|
|
126
|
-
];
|
|
127
|
-
const ENDOPHORIC = [
|
|
128
|
-
/\b(see|cf\.?) (Fig|Table|Section|Appendix|§)/gi,
|
|
129
|
-
/\((Appendix|Fig\.?|Table|Section|§)[^)]*\)/gi,
|
|
130
|
-
/\b(noted|discussed|shown|described) (above|below|earlier|previously)\b/gi,
|
|
131
|
-
/\bin (Section|Table|Figure|Appendix) \S+/gi,
|
|
132
|
-
];
|
|
133
|
-
const CODE_GLOSSES = [
|
|
134
|
-
/\bnamely\b/gi,
|
|
135
|
-
/\be\.g\.,?/gi,
|
|
136
|
-
/\bi\.e\.,?/gi,
|
|
137
|
-
/\bsuch as\b/gi,
|
|
138
|
-
/\bin other words\b/gi,
|
|
139
|
-
/\bthat is\b/gi,
|
|
140
|
-
/\bwhich means\b/gi,
|
|
141
|
-
];
|
|
142
|
-
const HEDGES = [
|
|
143
|
-
/\bmight\b/gi,
|
|
144
|
-
/\bmay\b/gi,
|
|
145
|
-
/\bcould\b/gi,
|
|
146
|
-
/\bperhaps\b/gi,
|
|
147
|
-
/\bpossibl[ey]\b/gi,
|
|
148
|
-
/\bprobabl[ey]\b/gi,
|
|
149
|
-
/\bsuggest(s|ive|ed)?\b/gi,
|
|
150
|
-
/\bappear(s|ed)?\b/gi,
|
|
151
|
-
/\bseem(s|ed)?\b/gi,
|
|
152
|
-
/\bindicate(s|d)?\b/gi,
|
|
153
|
-
/\brelatively\b/gi,
|
|
154
|
-
/\bsomewhat\b/gi,
|
|
155
|
-
/\bapparently\b/gi,
|
|
156
|
-
/\bnearly\b/gi,
|
|
157
|
-
/\btend(s|ed)? to\b/gi,
|
|
158
|
-
/\blargely\b/gi,
|
|
159
|
-
/\bgenerally\b/gi,
|
|
160
|
-
/\btypically\b/gi,
|
|
161
|
-
/\bin part\b/gi,
|
|
162
|
-
/\bto some extent\b/gi,
|
|
163
|
-
/\bassume(s|d)?\b/gi,
|
|
164
|
-
];
|
|
165
|
-
const BOOSTERS = [
|
|
166
|
-
/\bclearly\b/gi,
|
|
167
|
-
/\bobviously\b/gi,
|
|
168
|
-
/\bdefinitely\b/gi,
|
|
169
|
-
/\bin fact\b/gi,
|
|
170
|
-
/\bit is clear that\b/gi,
|
|
171
|
-
/\bof course\b/gi,
|
|
172
|
-
/\bmust\b/gi,
|
|
173
|
-
/\bcannot\b/gi,
|
|
174
|
-
/\bno\b(?= \w+ (can|could|will|would|is|are))/gi,
|
|
175
|
-
/\bnever\b/gi,
|
|
176
|
-
/\balways\b/gi,
|
|
177
|
-
/\bshow(s|ed)? that\b/gi,
|
|
178
|
-
/\bdemonstrate(s|d)?\b/gi,
|
|
179
|
-
];
|
|
180
|
-
const SELF_MENTION = [
|
|
181
|
-
/\bwe\b/gi,
|
|
182
|
-
/\bour\b/gi,
|
|
183
|
-
/\bus\b/gi,
|
|
184
|
-
/\bI\b/g,
|
|
185
|
-
/\bmy\b/gi,
|
|
186
|
-
];
|
|
187
|
-
const ENGAGEMENT = [
|
|
188
|
-
/\byou(r)?\b/gi,
|
|
189
|
-
/\bconsider\b/gi,
|
|
190
|
-
/\bnote that\b/gi,
|
|
191
|
-
/\bimagine\b/gi,
|
|
192
|
-
/\blet us\b/gi,
|
|
193
|
-
/\brecall\b/gi,
|
|
194
|
-
];
|
|
195
|
-
const NEGATORS = [
|
|
196
|
-
/\bnot\b/gi,
|
|
197
|
-
/\bno\b/gi,
|
|
198
|
-
/\bnone\b/gi,
|
|
199
|
-
/\bnever\b/gi,
|
|
200
|
-
/\bcannot\b/gi,
|
|
201
|
-
/\bn't\b/gi,
|
|
202
|
-
/\bneither\b/gi,
|
|
203
|
-
/\bnor\b/gi,
|
|
204
|
-
/\bwithout\b/gi,
|
|
205
|
-
/\bfail(s|ed)? to\b/gi,
|
|
206
|
-
/\bunable\b/gi,
|
|
207
|
-
];
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* `rather than` — moved OUT of EPANORTHOSIS on 2026-08-05, and the reason is arithmetic, not taste.
|
|
211
|
-
*
|
|
212
|
-
* The threshold above compares our count against Boggia's measured baselines (human 3.6, LLM 7.8 per
|
|
213
|
-
* 10k). Those were measured on "not X, but Y". `rather than` is a different construction and a
|
|
214
|
-
* mostly innocent English connective — "we report the direction rather than restate corpus shares"
|
|
215
|
-
* is fine writing. Counting it in the same numerator while comparing against that denominator makes
|
|
216
|
-
* the headline number incomparable to the baseline it is printed next to, which is a measurement bug
|
|
217
|
-
* of exactly the kind this paper is about.
|
|
218
|
-
*
|
|
219
|
-
* It still gets reported, on its own line, because a pile of them is a real register problem — it
|
|
220
|
-
* just is not epanorthosis and must not borrow epanorthosis's baseline. No published baseline exists
|
|
221
|
-
* for it, so the threshold is ours and generous.
|
|
222
|
-
*/
|
|
223
|
-
const CONTRASTIVE = [
|
|
224
|
-
/\brather than\b/gi,
|
|
225
|
-
/\binstead of\b/gi,
|
|
226
|
-
/\bas opposed to\b/gi,
|
|
227
|
-
];
|
|
228
|
-
// nominalisations: -tion/-sion/-ment/-ance/-ence/-ity/-ness/-ing used as head noun (approximate)
|
|
229
|
-
const NOMINAL = /\b\w{4,}(tion|sion|ment|ance|ence|ity|ness)s?\b/gi;
|
|
230
|
-
|
|
231
|
-
/** Matches of every pattern in the lexicon `pats`, summed. Every caller passes a lexicon array. */
|
|
232
|
-
const count = (t, pats) =>
|
|
233
|
-
pats.reduce((n, p) => n + (t.match(p) || []).length, 0);
|
|
234
|
-
// 🔴 Next to this lived `listHits(t, pats)` — the same walk, but returning THE MATCHES THEMSELVES
|
|
235
|
-
// rather than their count. Nobody called it (`no-unused-vars`, 2026-08-28), and that is not a
|
|
236
|
-
// trifle: the paragraph below explains that a metric was ignored precisely because it could not NAME
|
|
237
|
-
// the offender ("A miscounted metric does not get argued with; it gets ignored"). `listHits` was the
|
|
238
|
-
// remedy, and it was not wired into the report. Deleted; the hole — "the report prints counters
|
|
239
|
-
// without the offending lines" — is recorded here.
|
|
240
|
-
|
|
241
|
-
// 🔴 Paragraph boundaries END a sentence. The first version collapsed all whitespace first, so a
|
|
242
|
-
// heading ran into the paragraph under it and the last sentence of one paragraph ran into the first
|
|
243
|
-
// of the next. Measured 2026-08-05: that inflated "sentences carrying >2
|
|
244
|
-
// propositions" to 55, and the top offenders printed by the report were not sentences at all —
|
|
245
|
-
// they were a title glued to an abstract. The metric therefore looked like noise, which is exactly
|
|
246
|
-
// why nobody ever wired it into the flags that hooks and pre-commit consume. A miscounted metric
|
|
247
|
-
// does not get argued with; it gets ignored.
|
|
248
|
-
// Headings never reach this function: the paper's prose comes without them (`paperProse`), and a
|
|
249
|
-
// rendered page sets them as lines of their own.
|
|
250
|
-
function splitSentences(t) {
|
|
251
|
-
return t
|
|
252
|
-
.split(/\n\s*\n/) // paragraphs never run together
|
|
253
|
-
.flatMap((p) =>
|
|
254
|
-
p
|
|
255
|
-
.split("\n")
|
|
256
|
-
.join(" ")
|
|
257
|
-
.replace(/\s+/g, " ")
|
|
258
|
-
.split(/(?<=[.!?])\s+(?=[A-Z“"(*`])/),
|
|
259
|
-
)
|
|
260
|
-
.map((s) => s.trim())
|
|
261
|
-
.filter(Boolean);
|
|
262
|
-
}
|
|
263
|
-
const words = (t) => (t.match(/[A-Za-z0-9%.'’-]+/g) || []).length;
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* The metrics of `text`, whose sentences the caller split and found non-empty — the same array is
|
|
267
|
-
* passed in rather than split again, so the check the caller made is the one the division relies on.
|
|
268
|
-
*/
|
|
269
|
-
function analyse(text, sents) {
|
|
270
|
-
const W = words(text),
|
|
271
|
-
per1k = (n) => +((n / W) * 1000).toFixed(1);
|
|
272
|
-
const lens = sents.map(words);
|
|
273
|
-
const mean = lens.reduce((a, b) => a + b, 0) / lens.length;
|
|
274
|
-
const sd = Math.sqrt(
|
|
275
|
-
lens.reduce((a, b) => a + (b - mean) ** 2, 0) / lens.length,
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
const cats = {
|
|
279
|
-
frameMarkers: count(text, FRAME_MARKERS),
|
|
280
|
-
transitions: count(text, TRANSITIONS),
|
|
281
|
-
endophoric: count(text, ENDOPHORIC),
|
|
282
|
-
codeGlosses: count(text, CODE_GLOSSES),
|
|
283
|
-
hedges: count(text, HEDGES),
|
|
284
|
-
boosters: count(text, BOOSTERS),
|
|
285
|
-
selfMention: count(text, SELF_MENTION),
|
|
286
|
-
engagement: count(text, ENGAGEMENT),
|
|
287
|
-
};
|
|
288
|
-
const mdTotal = Object.values(cats).reduce((a, b) => a + b, 0);
|
|
289
|
-
|
|
290
|
-
// Per sentence: the wasted stress position, negation and the topic position.
|
|
291
|
-
const perSent = sents.map((s) => {
|
|
292
|
-
const sw = words(s);
|
|
293
|
-
const frame = count(s, FRAME_MARKERS);
|
|
294
|
-
// stress position: last ~8 words
|
|
295
|
-
const tail = s.split(/\s+/).slice(-8).join(" ");
|
|
296
|
-
const wastedStress =
|
|
297
|
-
/\((Appendix|Fig|Table|Section|§)[^)]*\)\.?$/i.test(s.trim()) ||
|
|
298
|
-
/\[\d+([,–-]\s*\d+)*\]\.?$/.test(s.trim()) ||
|
|
299
|
-
// a RESULT number = %, or a digit that is not part of a section/appendix/figure pointer
|
|
300
|
-
(count(tail, HEDGES) > 0 &&
|
|
301
|
-
/%|\b\d+(\.\d+)?\b/.test(
|
|
302
|
-
s.replace(
|
|
303
|
-
/\b(Appendix|Fig\.?|Table|Section|§)\s*[A-Z]?\.?\d+(\.\d+)*/gi,
|
|
304
|
-
"",
|
|
305
|
-
),
|
|
306
|
-
) &&
|
|
307
|
-
!/%|\b\d+(\.\d+)?\b/.test(
|
|
308
|
-
tail.replace(
|
|
309
|
-
/\b(Appendix|Fig\.?|Table|Section|§)\s*[A-Z]?\.?\d+(\.\d+)*/gi,
|
|
310
|
-
"",
|
|
311
|
-
),
|
|
312
|
-
));
|
|
313
|
-
const negMain = count(s, NEGATORS) > 0;
|
|
314
|
-
// topic position = first 5 words
|
|
315
|
-
const topic = s.split(/\s+/).slice(0, 5).join(" ").toLowerCase();
|
|
316
|
-
return {
|
|
317
|
-
s,
|
|
318
|
-
sw,
|
|
319
|
-
frame,
|
|
320
|
-
wastedStress,
|
|
321
|
-
negMain,
|
|
322
|
-
topic,
|
|
323
|
-
hedges: count(s, HEDGES),
|
|
324
|
-
definites: s.match(/\bthe [a-z][a-z-]*(\s+[a-z][a-z-]*)?\b/g) || [],
|
|
325
|
-
};
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
const negPct = Math.round(
|
|
329
|
-
(perSent.filter((p) => p.negMain).length / sents.length) * 100,
|
|
330
|
-
);
|
|
331
|
-
return {
|
|
332
|
-
words: W,
|
|
333
|
-
sentences: sents.length,
|
|
334
|
-
sentenceLens: lens,
|
|
335
|
-
meanLen: +mean.toFixed(1),
|
|
336
|
-
sdLen: +sd.toFixed(1),
|
|
337
|
-
cv: +(sd / mean).toFixed(2),
|
|
338
|
-
per1k: Object.fromEntries(
|
|
339
|
-
Object.entries(cats).map(([k, v]) => [k, per1k(v)]),
|
|
340
|
-
),
|
|
341
|
-
raw: cats,
|
|
342
|
-
metadiscoursePer1000: per1k(mdTotal),
|
|
343
|
-
nominalisationsPer1000: per1k((text.match(NOMINAL) || []).length),
|
|
344
|
-
contrastivePer10k: +((count(text, CONTRASTIVE) / W) * 10000).toFixed(1),
|
|
345
|
-
wastedStress: perSent.filter((p) => p.wastedStress).map((p) => p.s),
|
|
346
|
-
negatedSentencePct: negPct,
|
|
347
|
-
topics: perSent.map((p) => p.topic),
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/** The `.tex` files of `figures/` beside a rendered page, each as `{ file, text }`. */
|
|
352
|
-
function figureFiles(pagePath, fs, path) {
|
|
353
|
-
const dir = path.join(path.dirname(pagePath), "figures");
|
|
354
|
-
let files; // no initialiser: the catch branch returns, only try assigns (2026-08-28)
|
|
355
|
-
try {
|
|
356
|
-
files = fs.readdirSync(dir).filter((f) => f.endsWith(".tex"));
|
|
357
|
-
} catch {
|
|
358
|
-
return [];
|
|
359
|
-
}
|
|
360
|
-
return files.map((f) => ({
|
|
361
|
-
file: `figures/${f}`,
|
|
362
|
-
text: fs.readFileSync(path.join(dir, f), "utf8"),
|
|
363
|
-
}));
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Every `\caption` of `sources` (`{ file, text }`) a reader sees, measured. The captions come from the
|
|
368
|
-
* parsed source (`captionsOf`, src/adapters/latex/captions.ts): its optional argument, star and spacing
|
|
369
|
-
* are the parser's, and a caption that is commented out, in verbatim or in a macro's definition is not one.
|
|
370
|
-
*/
|
|
371
|
-
function captions(sources) {
|
|
372
|
-
return sources.flatMap(({ file, text }) =>
|
|
373
|
-
captionsOf(parseLatex(text)).map((raw) => {
|
|
374
|
-
// A dash with no spaces round it joins two words in the count, as it never did here.
|
|
375
|
-
const caption = raw.replace(/---/g, " ");
|
|
376
|
-
const sents = splitSentences(caption);
|
|
377
|
-
return {
|
|
378
|
-
file,
|
|
379
|
-
words: words(caption),
|
|
380
|
-
longest: Math.max(...sents.map(words)),
|
|
381
|
-
longestSentence: sents.slice().sort((a, b) => words(b) - words(a))[0],
|
|
382
|
-
};
|
|
383
|
-
}),
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* The findings on the captions of the file `f`: one line per caption sentence or caption over its
|
|
389
|
-
* limit. A paper's captions are in its own files — paper.tex and what it includes, wherever a figure
|
|
390
|
-
* is set; a rendered page has the `.tex` of `figures/` beside it. The report and `--flags-only` both
|
|
391
|
-
* read them from here.
|
|
392
|
-
*/
|
|
393
|
-
function captionFindings(f, tex, fs, path) {
|
|
394
|
-
return captions(tex ? tex.files : figureFiles(f, fs, path)).flatMap((c) =>
|
|
395
|
-
CAPTION_LIMITS.filter(over(c)).map(say(c)),
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* The two limits a caption is held to: the `THRESHOLDS` key, what of a caption it is measured on, and
|
|
401
|
-
* how a finding reads. A caption is over a limit when its measure exceeds the threshold's `warn`.
|
|
402
|
-
*/
|
|
403
|
-
const CAPTION_LIMITS = [
|
|
404
|
-
{
|
|
405
|
-
key: "captionSentenceWords",
|
|
406
|
-
measure: (c) => c.longest,
|
|
407
|
-
say: (c, warn) =>
|
|
408
|
-
`${c.file}: caption sentence of ${c.longest} words (warn >${warn}) — "${c.longestSentence.slice(0, 110)}…"`,
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
key: "captionWords",
|
|
412
|
-
measure: (c) => c.words,
|
|
413
|
-
say: (c, warn) =>
|
|
414
|
-
`${c.file}: caption is ${c.words} words (warn >${warn}) — a caption this long is a section under a picture`,
|
|
415
|
-
},
|
|
416
|
-
];
|
|
417
|
-
const over = (c) => (limit) => limit.measure(c) > THRESHOLDS[limit.key].warn;
|
|
418
|
-
const say = (c) => (limit) => limit.say(c, THRESHOLDS[limit.key].warn);
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Every line of the report as data, in the order it is printed: `ok` is true (passed), false (a
|
|
422
|
-
* finding, marked `FLAG`) or null (a figure, no check), `under` the lines that name the offenders.
|
|
423
|
-
* The report prints all of it; `--flags-only` prints the findings: one list, two renderings.
|
|
424
|
-
*/
|
|
425
|
-
function checks(r, captionLines) {
|
|
426
|
-
const T = THRESHOLDS;
|
|
427
|
-
return [
|
|
428
|
-
{
|
|
429
|
-
ok: r.metadiscoursePer1000 <= T.metadiscourseTotalPer1000.warn,
|
|
430
|
-
text: `all metadiscourse/1000w ${r.metadiscoursePer1000} (Hyland RA baseline 64.9, warn >${T.metadiscourseTotalPer1000.warn})`,
|
|
431
|
-
under: [],
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
ok: null,
|
|
435
|
-
text: `nominalisations/1000w ${r.nominalisationsPer1000}`,
|
|
436
|
-
under: [],
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
ok: r.contrastivePer10k <= T.contrastivePer10k.warn,
|
|
440
|
-
text: `"rather than"/instead-of/10,000w ${r.contrastivePer10k} (warn >${T.contrastivePer10k.warn}; not epanorthosis, no published baseline)`,
|
|
441
|
-
under: [],
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
ok: r.wastedStress.length === 0,
|
|
445
|
-
text: `sentences ending on a cross-ref/citation/hedge (wasted stress position): ${r.wastedStress.length}`,
|
|
446
|
-
under: r.wastedStress.map((s) => `…${s.slice(-70)}`),
|
|
447
|
-
},
|
|
448
|
-
{
|
|
449
|
-
ok: r.negatedSentencePct <= T.negatedMainClausePct.warn,
|
|
450
|
-
text: `sentences whose main claim is a negation: ${r.negatedSentencePct}%`,
|
|
451
|
-
under: [],
|
|
452
|
-
},
|
|
453
|
-
{
|
|
454
|
-
ok: captionLines.length === 0,
|
|
455
|
-
text: `figure captions over the limit: ${captionLines.length}`,
|
|
456
|
-
under: captionLines,
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
ok: null,
|
|
460
|
-
text: `topic positions (whose story is this?): ${r.topics.map((t) => `"${t}"`).join(" | ")}`,
|
|
461
|
-
under: [],
|
|
462
|
-
},
|
|
463
|
-
];
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
const MARK = { true: "ok ", false: "FLAG", null: " " };
|
|
467
|
-
|
|
468
|
-
function report(name, r, rows) {
|
|
469
|
-
console.log(`\n=== ${name} — ${r.words} words, ${r.sentences} sentences ===`);
|
|
470
|
-
console.log(
|
|
471
|
-
`sentence lengths ${JSON.stringify(r.sentenceLens)} mean ${r.meanLen} sd ${r.sdLen} CV ${r.cv}`,
|
|
472
|
-
);
|
|
473
|
-
rows.forEach(({ ok, text, under }) => {
|
|
474
|
-
console.log(`${MARK[ok]} ${text}`);
|
|
475
|
-
under.forEach((l) => console.log(` > ${l}`));
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
const args = process.argv.slice(2);
|
|
480
|
-
if (args.length === 0) {
|
|
481
|
-
console.error(
|
|
482
|
-
"usage: node prose-lint.mjs <paper.tex|page.txt> [more files] [--flags-only|--headings]",
|
|
483
|
-
);
|
|
484
|
-
process.exit(0);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
// A paper's source is its `paper.tex`, and a `.txt` is its rendered page. Anything else would be
|
|
488
|
-
// measured as if it were prose, with no way to tell its markup from its sentences.
|
|
489
|
-
const unread = args.filter(
|
|
490
|
-
(a) => !a.startsWith("--") && !a.endsWith(".tex") && !a.endsWith(".txt"),
|
|
491
|
-
);
|
|
492
|
-
if (unread.length) {
|
|
493
|
-
console.error(
|
|
494
|
-
`prose-lint reads a paper.tex or the text of its rendered PDF (.txt), not: ${unread.join(", ")}`,
|
|
495
|
-
);
|
|
496
|
-
process.exit(2);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
const fs = await import("node:fs");
|
|
500
|
-
const path = await import("node:path");
|
|
501
|
-
|
|
502
|
-
// 🔴 The RENDERED page, not only the source. Added 2026-08-05 after the author asked why the render
|
|
503
|
-
// step had not caught a stall he found by opening the PDF. It had not because nothing reads the
|
|
504
|
-
// rendered text: the build checks FORM — page count, overfull boxes, unresolved references, unset
|
|
505
|
-
// characters, the anonymity grep — and never looks at a sentence, while every prose check reads the
|
|
506
|
-
// source and never sees a typeset page. Between those two layers sat every
|
|
507
|
-
// defect he found by eye, and he was the only reader of the artifact a reviewer actually gets.
|
|
508
|
-
function pdfTextOnly(t) {
|
|
509
|
-
const cut = t.search(/^\s*References\s*$/m);
|
|
510
|
-
if (cut > 0) t = t.slice(0, cut);
|
|
511
|
-
return t
|
|
512
|
-
.replace(/^\s*\d+\s*$/gm, "") // page numbers
|
|
513
|
-
.replace(/(\w)-\n(\w)/g, "$1$2") // hyphenation introduced by the two-column set
|
|
514
|
-
.replace(/\f/g, "\n\n");
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
// `--flags-only` prints the findings of the report (every line it marks FLAG, with the lines under
|
|
518
|
-
// it) and nothing on a clean paper, and exits 1 when there is one: the form for a hook. The report
|
|
519
|
-
// prints all of `checks` and exits 0.
|
|
520
|
-
const mode = args.includes("--flags-only")
|
|
521
|
-
? "flags"
|
|
522
|
-
: args.includes("--headings")
|
|
523
|
-
? "headings"
|
|
524
|
-
: "report";
|
|
525
|
-
let flagged = 0;
|
|
526
|
-
for (const f of args.filter((a) => !a.startsWith("--"))) {
|
|
527
|
-
const raw = fs.readFileSync(f, "utf8");
|
|
528
|
-
const deps = { files: nodeFiles, latex: latexReader, codec: sourcesCodec };
|
|
529
|
-
const tex = f.endsWith(".tex")
|
|
530
|
-
? paperProse(path.resolve(f), raw, deps)
|
|
531
|
-
: null;
|
|
532
|
-
if (tex && paperRecord(path.dirname(path.resolve(f)), deps).kind !== "fresh")
|
|
533
|
-
console.error(
|
|
534
|
-
`prose-lint: ${f} has no current build record (_build/sources.json), so only paper.tex was read, not the files it includes — run \`npx paperlint build\` first`,
|
|
535
|
-
);
|
|
536
|
-
// 🔴 NOTHING LEFT IS NOT "CLEAN". A body that strips to no words used to be analysed anyway: every
|
|
537
|
-
// metric is a fraction of the word count, so the report printed NaN, FLAGged three metrics and
|
|
538
|
-
// exited 0. Refused — no number is better than a meaningless one. The test is on sentences: a
|
|
539
|
-
// zero sentence count divides just the same as a zero word count.
|
|
540
|
-
const text = tex ? tex.body : pdfTextOnly(raw);
|
|
541
|
-
const sentences = splitSentences(text);
|
|
542
|
-
if (sentences.length === 0) {
|
|
543
|
-
console.error(
|
|
544
|
-
tex
|
|
545
|
-
? `prose-lint: ${f} has no prose to measure — after the preamble, comments, floats and ` +
|
|
546
|
-
"the back matter are left out, no word is left."
|
|
547
|
-
: `prose-lint: ${f} has no prose to measure — no sentence is left before the references.`,
|
|
548
|
-
);
|
|
549
|
-
process.exit(2);
|
|
550
|
-
}
|
|
551
|
-
const r = analyse(text, sentences);
|
|
552
|
-
const rows = () => checks(r, captionFindings(f, tex, fs, path));
|
|
553
|
-
if (mode === "flags") {
|
|
554
|
-
const found = rows().filter((row) => row.ok === false);
|
|
555
|
-
if (found.length) {
|
|
556
|
-
flagged += found.length;
|
|
557
|
-
// The header STATES the count, so a caller need not count output lines — header and footer
|
|
558
|
-
// are not findings.
|
|
559
|
-
console.error(
|
|
560
|
-
`✍️ prose-lint — ${f.split("/").pop()} — ${found.length} finding(s):`,
|
|
561
|
-
);
|
|
562
|
-
found.forEach(({ text, under }) => {
|
|
563
|
-
console.error(` ${text}`);
|
|
564
|
-
under.forEach((l) => console.error(` > ${l}`));
|
|
565
|
-
});
|
|
566
|
-
console.error(
|
|
567
|
-
" run prose-lint.mjs on the file without --flags-only for every metric",
|
|
568
|
-
);
|
|
569
|
-
}
|
|
570
|
-
} else if (mode === "headings") {
|
|
571
|
-
// The whole-document question, printed as one list. Not a gate: "does this heading name a
|
|
572
|
-
// concrete noun" is judgement and pretending otherwise would be the exact failure this file
|
|
573
|
-
// exists to stop. What was missing is cheaper and was the real cause — nobody had ever seen the
|
|
574
|
-
// headings AS A SET. Two that a reader called "VAGUE AF" and "why not mention the linter??"
|
|
575
|
-
// survived six passes because every pass looked only at the section it was editing.
|
|
576
|
-
if (!tex) {
|
|
577
|
-
console.error(
|
|
578
|
-
`prose-lint: --headings reads a paper.tex — a rendered page (${f}) marks no heading`,
|
|
579
|
-
);
|
|
580
|
-
process.exit(2);
|
|
581
|
-
}
|
|
582
|
-
console.log(`\n=== ${f.split("/").pop()} — every heading, in order ===`);
|
|
583
|
-
tex.headings.forEach((h, i) =>
|
|
584
|
-
console.log(`${String(i + 1).padStart(3)}. ${h}`),
|
|
585
|
-
);
|
|
586
|
-
console.log(
|
|
587
|
-
"\nRead these as a stranger who will read nothing else. Each should name a thing:",
|
|
588
|
-
);
|
|
589
|
-
console.log(
|
|
590
|
-
'a linter, a configuration, a repository, a rule — not "answers", "kinds", "moves".',
|
|
591
|
-
);
|
|
592
|
-
} else {
|
|
593
|
-
report(f.split("/").pop(), r, rows());
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
if (mode !== "flags")
|
|
597
|
-
console.log(
|
|
598
|
-
"\n(thresholds and their sources are in THRESHOLDS at the top of this file)",
|
|
599
|
-
);
|
|
600
|
-
// Exit 1 on a flag so a caller can branch. Hooks stay advisory by swallowing it themselves; the
|
|
601
|
-
// point is that the information now EXISTS at the exit code, where it was previously unreachable.
|
|
602
|
-
process.exit(flagged ? 1 : 0);
|