paperlint 4.2.0 → 5.0.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.
Files changed (119) hide show
  1. package/CLAUDE.md +2 -2
  2. package/README.md +15 -4
  3. package/action.harness.mjs +54 -36
  4. package/action.yml +12 -27
  5. package/dist/adapters/latex/includes.d.ts +5 -1
  6. package/dist/adapters/latex/includes.d.ts.map +1 -1
  7. package/dist/adapters/latex/includes.js +8 -2
  8. package/dist/adapters/latex/includes.js.map +1 -1
  9. package/dist/build.d.ts.map +1 -1
  10. package/dist/build.js +7 -3
  11. package/dist/build.js.map +1 -1
  12. package/dist/cli.d.ts +2 -8
  13. package/dist/cli.d.ts.map +1 -1
  14. package/dist/cli.js +67 -37
  15. package/dist/cli.js.map +1 -1
  16. package/dist/domain/paper-source.js +2 -2
  17. package/dist/eslint-rules/latex-language.d.ts +5 -1
  18. package/dist/eslint-rules/latex-language.d.ts.map +1 -1
  19. package/dist/eslint-rules/latex-language.js +6 -3
  20. package/dist/eslint-rules/latex-language.js.map +1 -1
  21. package/dist/eslint-rules/paper-context.d.ts +20 -0
  22. package/dist/eslint-rules/paper-context.d.ts.map +1 -0
  23. package/dist/eslint-rules/paper-context.js +44 -0
  24. package/dist/eslint-rules/paper-context.js.map +1 -0
  25. package/dist/eslint-rules/paper-typography.d.ts +1 -1
  26. package/dist/eslint-rules/paper-typography.d.ts.map +1 -1
  27. package/dist/eslint-rules/paper-typography.js +32 -18
  28. package/dist/eslint-rules/paper-typography.js.map +1 -1
  29. package/dist/eslint-rules/tex-build.d.ts.map +1 -1
  30. package/dist/eslint-rules/tex-build.js +7 -1
  31. package/dist/eslint-rules/tex-build.js.map +1 -1
  32. package/dist/init.d.ts +4 -19
  33. package/dist/init.d.ts.map +1 -1
  34. package/dist/init.js +24 -29
  35. package/dist/init.js.map +1 -1
  36. package/dist/package-dirs.d.ts +2 -0
  37. package/dist/package-dirs.d.ts.map +1 -1
  38. package/dist/package-dirs.js +8 -0
  39. package/dist/package-dirs.js.map +1 -1
  40. package/dist/paper-files.d.ts +2 -2
  41. package/dist/paper-includes.d.ts +17 -0
  42. package/dist/paper-includes.d.ts.map +1 -0
  43. package/dist/paper-includes.js +51 -0
  44. package/dist/paper-includes.js.map +1 -0
  45. package/dist/rules-config.d.ts +1 -0
  46. package/dist/rules-config.d.ts.map +1 -1
  47. package/dist/rules-config.js.map +1 -1
  48. package/dist/structure.js +1 -1
  49. package/dist/structure.js.map +1 -1
  50. package/dist/tex-paper.d.ts +17 -3
  51. package/dist/tex-paper.d.ts.map +1 -1
  52. package/dist/tex-paper.js +36 -38
  53. package/dist/tex-paper.js.map +1 -1
  54. package/docs/configuration.md +5 -4
  55. package/docs/install.md +8 -8
  56. package/docs/prior-art/paper-folder-scaffolding.md +4 -7
  57. package/docs/rules.md +15 -11
  58. package/eslint-rules/latex-language.ts +10 -4
  59. package/eslint-rules/paper-context.test.ts +47 -0
  60. package/eslint-rules/paper-context.ts +57 -0
  61. package/eslint-rules/paper-typography.ts +67 -23
  62. package/eslint-rules/tex-build.ts +8 -1
  63. package/fixtures/real-markdown-paper/baseline.json +1 -2
  64. package/package.json +1 -1
  65. package/scripts/check.ts +2 -2
  66. package/scripts/eslint-report-guard.mjs +5 -2
  67. package/scripts/harness-api.frozen.json +0 -1
  68. package/skills/paper-pipeline/references/pipeline-status-template.md +2 -16
  69. package/src/adapters/latex/includes.ts +10 -2
  70. package/src/adapters/latex/index.test.ts +8 -0
  71. package/src/build.harness.mjs +4 -2
  72. package/src/build.test.ts +18 -1
  73. package/src/build.ts +7 -3
  74. package/src/cli.harness.mjs +22 -54
  75. package/src/cli.test.ts +2 -18
  76. package/src/cli.ts +78 -42
  77. package/src/domain/paper-source.ts +2 -2
  78. package/src/init.test.ts +33 -13
  79. package/src/init.ts +25 -48
  80. package/src/linted-set.test.ts +11 -1
  81. package/src/new-paper.harness.mjs +1 -5
  82. package/src/package-dirs.ts +9 -0
  83. package/src/paper-files.ts +2 -2
  84. package/src/paper-includes.test.ts +161 -0
  85. package/src/paper-includes.ts +77 -0
  86. package/src/rule-cases.test.ts +0 -30
  87. package/src/rule-docs.test.ts +0 -1
  88. package/src/rules-config.ts +1 -0
  89. package/src/structure.harness.ts +1 -3
  90. package/src/structure.ts +1 -1
  91. package/src/tex-paper.test.ts +78 -61
  92. package/src/tex-paper.ts +57 -48
  93. package/src/tex-venue-rules.test.ts +1 -1
  94. package/templates/paper/PIPELINE-STATUS.md +0 -4
  95. package/dist/action-ref.d.ts +0 -12
  96. package/dist/action-ref.d.ts.map +0 -1
  97. package/dist/action-ref.js +0 -16
  98. package/dist/action-ref.js.map +0 -1
  99. package/dist/eslint-rules/paper-research-question.d.ts +0 -31
  100. package/dist/eslint-rules/paper-research-question.d.ts.map +0 -1
  101. package/dist/eslint-rules/paper-research-question.js +0 -188
  102. package/dist/eslint-rules/paper-research-question.js.map +0 -1
  103. package/docs/rules/tex/missing-input.md +0 -58
  104. package/eslint-rules/paper-research-question.harness.mjs +0 -212
  105. package/eslint-rules/paper-research-question.ts +0 -199
  106. package/fixtures/paper-research-question/comment-only/PIPELINE-STATUS.md +0 -9
  107. package/fixtures/paper-research-question/comment-only/paper.tex +0 -7
  108. package/fixtures/paper-research-question/declared-not-in-paper/PIPELINE-STATUS.md +0 -10
  109. package/fixtures/paper-research-question/declared-not-in-paper/paper.tex +0 -6
  110. package/fixtures/paper-research-question/draft/PIPELINE-STATUS.md +0 -6
  111. package/fixtures/paper-research-question/draft/paper.tex +0 -2
  112. package/fixtures/paper-research-question/markdown-no-rq/PIPELINE-STATUS.md +0 -9
  113. package/fixtures/paper-research-question/markdown-no-rq/paper.md +0 -4
  114. package/fixtures/paper-research-question/shipped-no-rq/PIPELINE-STATUS.md +0 -12
  115. package/fixtures/paper-research-question/shipped-no-rq/paper.tex +0 -3
  116. package/fixtures/paper-research-question/shipped-with-rq/PIPELINE-STATUS.md +0 -10
  117. package/fixtures/paper-research-question/shipped-with-rq/paper.tex +0 -2
  118. package/src/action-ref.test.ts +0 -26
  119. package/src/action-ref.ts +0 -15
@@ -1,199 +0,0 @@
1
- /**
2
- * `paper/research-question` — a shipped paper states its research question EXPLICITLY.
3
- *
4
- * Reviewer A's verbatim point on agenticdev (#20), as it was parsed: "State the goal as a
5
- * research question." This is a venue expectation, not taste: an empirical paper that never
6
- * names the question it answers forces the reviewer to reconstruct it — and they say so.
7
- *
8
- * ── WHY THE SCOPE IS SHIPPED PAPERS ONLY ─────────────────────────────────────────────────
9
- * A draft never asked anyone to read it. The scope deliberately matches `paper/author-list`:
10
- * both are about the DEBT of a shipped paper, and an unshipped one has no debt. Measured on the
11
- * live corpus before the move:
12
- * agenticdev-2026 has RQ, shipped -> silent (added because of this very review)
13
- * aisec-2026 no RQ, shipped -> a finding
14
- * compile-rules no RQ, shipped -> a finding
15
- * scored-2026 no RQ, NOT shipped -> silent
16
- *
17
- * ── WHAT THE MOVE CHANGED ─────────────────────────────────────────────────────────────────
18
- * The predecessor read the stage with a REGEX OVER THE SCORECARD'S PROSE. Remeasured 2026-09-17:
19
- * for `agenticdev-2026` the prose reads `submitted`, while the `stages` field declares
20
- * `submitted, camera-ready`. Here the stage comes from the FIELD — the same one `paper/stages`
21
- * checks against the bytes in both directions.
22
- *
23
- * ⚠️ WHAT THE MOVE DOES NOT FIX, AND THIS IS MEASURED, NOT ASSUMED. The rule reads RAW text, not
24
- * the parsed tree, so a mention of RQ inside a LaTeX comment (`% add an RQ`) will put it to
25
- * sleep. Measured 2026-09-17 across all four papers: ZERO such cases — not a single match inside
26
- * a comment. So the hole is LATENT, not observed, and closing it with a tree walk would
27
- * complicate the rule without a measured difference. The neighboring `paper/typography` is built
28
- * the same way and for the same reason. Once a real case shows up, there will be something to
29
- * cite here.
30
- *
31
- * The rule is ADVISORY by decision, not by coincidence: a position paper may legitimately have
32
- * no question. Then its absence is the author's decision, and the rule says exactly that,
33
- * rather than declaring the absence a defect on its own.
34
- */
35
- import { existsSync, readFileSync } from "node:fs";
36
- import { join, dirname } from "node:path";
37
- import { load } from "js-yaml";
38
- import { z } from "zod";
39
- import type { RuleContext } from "./rule-context.ts";
40
-
41
- /**
42
- * The two scorecard fields this rule reads, parsed rather than trusted: a field of the wrong shape
43
- * reads as absent, the way `data?.stages` on a string or a number always did.
44
- */
45
- const Scorecard = z
46
- .looseObject({
47
- stages: z.array(z.unknown()).catch([]),
48
- researchQuestion: z.string().catch(""),
49
- })
50
- .catch({ stages: [], researchQuestion: "" });
51
- const StageEntry = z.looseObject({ stage: z.unknown().optional() }).catch({});
52
- const RuleOptions = z
53
- .object({ statusFile: z.string().default("PIPELINE-STATUS.md") })
54
- .default({ statusFile: "PIPELINE-STATUS.md" });
55
-
56
- /**
57
- * 🔴 THE REGEX IS GONE, AND THE REASON IS NOT "regexes are bad" — IT IS THAT IT ANSWERED THE
58
- * WRONG QUESTION (2026-09-19).
59
- *
60
- * What stood here was `/\\textbf\{RQ|\bRQ[0-9]?\b|research question/i`, defended in this very
61
- * file with: "a regex is LEGITIMATE here: the subject is human prose, which has no structure by
62
- * definition, and no parser can tell a question's statement apart from a paragraph about it."
63
- *
64
- * The premise is true. The conclusion does not follow. From "the text cannot decide this" the
65
- * answer is not "so pattern-match harder" — it is "so the HUMAN declares it, and the check
66
- * compares the declaration against the text." The three spellings were an undeclared schema
67
- * field: someone added a fact and invented a convention for how it would look in prose, which is
68
- * the design running backwards.
69
- *
70
- * What the pattern actually decided, in both directions:
71
- * • a paper that says "we leave the research question to future work" — MATCHED, and the rule
72
- * went silent on a paper that states no question at all;
73
- * • a paper whose question is written plainly ("Does pruning reduce review cost?") with no
74
- * "RQ" anywhere — NOT matched, and the rule reported a paper that does exactly what is asked.
75
- * An open list of spellings cannot be completed, so both failures are structural, not bugs.
76
- *
77
- * ── WHAT REPLACES IT: ONE UNDECIDABLE QUESTION BECOMES TWO DECIDABLE ONES ──────────────────
78
- * 1. Is the question WRITTEN DOWN? — `researchQuestion` in the scorecard's front matter. A
79
- * field, parsed by js-yaml, not a phrase hunted for in prose.
80
- * 2. Does the paper CONTAIN what was written down? — the declared sentence, whitespace
81
- * collapsed, compared against the source. Bytes, not spelling.
82
- *
83
- * This is the shape this package already uses twice, and for the same reason: `bytes`/
84
- * `sourceBytes` (a recorded number compared against the file on disk) and `paper/author-list`
85
- * (a recorded marker, because whether a cross-check ran is not visible in the paper). Neither
86
- * asks the prose a question the prose cannot answer.
87
- *
88
- * ⚠️ WHAT THIS STILL CANNOT DO, said plainly rather than implied: nothing here decides that the
89
- * declared sentence IS a research question. A declaration of "banana" passes step 1 and, if the
90
- * word appears in the paper, step 2. The rule guarantees that the author wrote a question down
91
- * and that the paper carries it — it does not grade the question. That is a human's job, and
92
- * pretending otherwise is what the regex was doing.
93
- */
94
-
95
- /** Whitespace is the only thing normalised: a sentence wrapped across lines is the same sentence. */
96
- const flatten = (t: string) => t.replace(/\s+/g, " ").trim().toLowerCase();
97
-
98
- /**
99
- * Both facts come out of ONE parse of the scorecard's front matter: the stages (has this paper
100
- * shipped?) and the declared question. Reading them separately would invite the two to be taken
101
- * from different revisions of the same file.
102
- */
103
- function scorecard(
104
- dir: string,
105
- statusName: string,
106
- ): { stages: unknown[]; question: string } {
107
- const p = join(dir, statusName);
108
- const none = { stages: [], question: "" };
109
- if (!existsSync(p)) return none;
110
- let text: string;
111
- try {
112
- text = readFileSync(p, "utf-8");
113
- } catch {
114
- return none;
115
- }
116
- const m = /^---\n([\s\S]*?)\n---/.exec(text);
117
- if (!m) return none;
118
- const [, front = ""] = m;
119
- let data: unknown;
120
- try {
121
- data = load(front);
122
- } catch {
123
- return none; // the unreadable YAML is already reported by `paper/stages`, on its own file
124
- }
125
- const { stages: raw, researchQuestion: question } = Scorecard.parse(data);
126
- const stages = raw.map((r) => StageEntry.parse(r).stage).filter(Boolean);
127
- return { stages, question };
128
- }
129
-
130
- export default {
131
- rules: {
132
- "research-question": {
133
- meta: {
134
- type: "suggestion" as const,
135
- docs: {
136
- description:
137
- "a paper that declares a stage states its research question explicitly — otherwise the reviewer reconstructs it themselves, and says so",
138
- },
139
- schema: [
140
- {
141
- type: "object",
142
- properties: {
143
- // The scorecard's name is a CONSUMER convention. The rule is declared on the
144
- // paper's source, so it has to name its neighbor itself rather than get it via a
145
- // config glob.
146
- statusFile: { type: "string" },
147
- },
148
- additionalProperties: false,
149
- },
150
- ],
151
- messages: {
152
- notDeclared:
153
- "the paper shipped (stage «{{stages}}») and its scorecard declares no `researchQuestion`. This is reviewer A's verbatim point on agenticdev (#20), not the linter's taste. Write the question down as a field, in your own words — the check cannot infer it from the prose, and the pattern that used to try matched «we leave the research question to future work» while missing a question stated plainly. Advisory: a position paper may legitimately have none, and then leaving the field out is a DECISION — record it as one",
154
- notInPaper:
155
- "the scorecard declares a research question the paper does not contain. Looked for «{{needle}}» with whitespace collapsed, and the source has no such run of text. Either the paper dropped it or the declaration drifted from what was written — and which of the two it is, only you know",
156
- },
157
- },
158
- create(context: RuleContext) {
159
- const { statusFile: statusName } = RuleOptions.parse(
160
- context.options[0],
161
- );
162
- return {
163
- // `root:exit` exists for both markdown and the `tex/latex` language — the same place
164
- // `paper/typography` lives, and for the same reason: a paper in this corpus can be
165
- // either.
166
- "root:exit"(node: object) {
167
- const raw = context.sourceCode.raw ?? context.sourceCode.text;
168
- if (typeof raw !== "string") return;
169
- const { stages, question } = scorecard(
170
- dirname(context.filename),
171
- statusName,
172
- );
173
- if (stages.length === 0) return; // not shipped — owes nothing
174
-
175
- // Step 1 — is it written down? A field, not a phrase hunted for in prose.
176
- if (question.trim() === "") {
177
- context.report({
178
- node,
179
- messageId: "notDeclared",
180
- data: { stages: stages.join("/") },
181
- });
182
- return;
183
- }
184
-
185
- // Step 2 — does the paper carry what was written down? Bytes, not spelling. Only
186
- // whitespace is normalised, because a sentence wrapped across source lines is the
187
- // same sentence; everything else stays the author's.
188
- if (flatten(raw).includes(flatten(question))) return;
189
- context.report({
190
- node,
191
- messageId: "notInPaper",
192
- data: { needle: flatten(question) },
193
- });
194
- },
195
- };
196
- },
197
- },
198
- },
199
- };
@@ -1,9 +0,0 @@
1
- ---
2
- stages:
3
- - stage: submitted
4
- date: 2026-07-22
5
- venue: A Venue 2026
6
- pdf: versions/2026-07-22-submitted.pdf
7
- bytes: 100
8
- ---
9
- # PIPELINE-STATUS
@@ -1,7 +0,0 @@
1
- \section{Introduction}
2
- % TODO: state the research question — this is a LaTeX COMMENT.
3
- % The rule reads RAW text and today does not tell it apart from the paper, so here it STAYS
4
- % SILENT. The hole is named in the rule's header and measured: on the live corpus there are
5
- % zero such cases, so it is latent. The fixture keeps it visible — the first real case turns
6
- % up and the assertion below has to be rewritten deliberately, not discovered after the fact.
7
- Body text of the paper, in which no question is stated.
@@ -1,10 +0,0 @@
1
- ---
2
- stages:
3
- - stage: submitted
4
- date: 2026-07-22
5
- venue: A Venue 2026
6
- pdf: versions/2026-07-22-submitted.pdf
7
- bytes: 100
8
- researchQuestion: "Does pruning reduce review cost?"
9
- ---
10
- # PIPELINE-STATUS
@@ -1,6 +0,0 @@
1
- \section{Introduction}
2
- % This fixture is the one the predecessor could not express. The scorecard declares a question;
3
- % the paper does not carry it. And the words "research question" DO appear below — so the old
4
- % pattern `/\textbf{RQ|\bRQ[0-9]?\b|research question/i` matched and went silent on a paper that
5
- % states no question at all. Matching a phrase ABOUT the thing is not finding the thing.
6
- We leave the research question to future work.
@@ -1,6 +0,0 @@
1
- ---
2
- stages: []
3
- ---
4
- # PIPELINE-STATUS
5
-
6
- A draft, never submitted anywhere.
@@ -1,2 +0,0 @@
1
- \section{Introduction}
2
- A draft with no question. Nobody was asked to read it.
@@ -1,9 +0,0 @@
1
- ---
2
- stages:
3
- - stage: submitted
4
- date: 2026-07-22
5
- venue: A Venue 2026
6
- pdf: versions/2026-07-22-submitted.pdf
7
- bytes: 100
8
- ---
9
- # PIPELINE-STATUS
@@ -1,4 +0,0 @@
1
- # Introduction
2
-
3
- The paper is written in markdown, not LaTeX — that happens in this corpus, and the rule must
4
- see it the same way. No question is stated here.
@@ -1,12 +0,0 @@
1
- ---
2
- stages:
3
- - stage: submitted
4
- date: 2026-07-22
5
- pdf: versions/a.pdf
6
- bytes: 1
7
- - stage: camera-ready
8
- date: 2026-08-29
9
- pdf: versions/b.pdf
10
- bytes: 2
11
- ---
12
- # PIPELINE-STATUS
@@ -1,3 +0,0 @@
1
- \section{Introduction}
2
- We study how agents behave and measure how many rules survive to the run.
3
- The question is named nowhere — neither by a macro nor in words.
@@ -1,10 +0,0 @@
1
- ---
2
- stages:
3
- - stage: submitted
4
- date: 2026-07-22
5
- venue: A Venue 2026
6
- pdf: versions/2026-07-22-submitted.pdf
7
- bytes: 100
8
- researchQuestion: "does a rule written in prose survive to the run?"
9
- ---
10
- # PIPELINE-STATUS
@@ -1,2 +0,0 @@
1
- \section{Introduction}
2
- \textbf{RQ1:} does a rule written in prose survive to the run?
@@ -1,26 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { test } from "vitest";
3
- import { actionRef } from "./action-ref.ts";
4
-
5
- /** [the running package's version, the ref `paperlint init` may pin the action to]. */
6
- const TABLE: readonly (readonly [string | undefined, string | null])[] = [
7
- ["1.2.3", "v1.2.3"],
8
- ["1.0.0", "v1.0.0"],
9
- ["10.20.30", "v10.20.30"],
10
- // Guards: a git checkout / `npm link` carries the unreleased placeholder — there is no tag for it.
11
- ["0.0.0-semantically-released", null],
12
- // Guards: only a plain release is known to have a tag; anything else stays the placeholder.
13
- ["1.2.3-beta.1", null],
14
- ["v1.2.3", null],
15
- ["1.2", null],
16
- ["", null],
17
- ["latest", null],
18
- [" 1.2.3", null],
19
- // Guards: the CLI could not read its own manifest — no version, no pin.
20
- [undefined, null],
21
- ];
22
-
23
- for (const [version, ref] of TABLE)
24
- test(`actionRef(${JSON.stringify(version)})`, () => {
25
- assert.equal(actionRef(version), ref);
26
- });
package/src/action-ref.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * The ref `paperlint init` pins the GitHub Action to, decided from the version of the package that is
3
- * running. semantic-release tags every release `v<version>` on the commit it publishes, so the
4
- * action at that tag is the same code as the installed package.
5
- *
6
- * Only a plain `X.Y.Z` has such a tag. A git checkout or `npm link` carries the unreleased
7
- * placeholder `0.0.0-semantically-released`, a version that could not be read is `undefined`, and
8
- * anything else is not known to be tagged: those return `null` ("no pin known"), and the caller
9
- * keeps the placeholder. A wrong tag written confidently is worse than an obvious placeholder.
10
- */
11
- export function actionRef(version: string | undefined): string | null {
12
- return version !== undefined && /^\d+\.\d+\.\d+$/.test(version)
13
- ? `v${version}`
14
- : null;
15
- }