paperlint 20.1.0 → 20.1.2

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 (86) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.github/workflows/ci.yml +7 -0
  3. package/CLAUDE.md +2 -2
  4. package/CONTRIBUTING.md +2 -2
  5. package/{action.harness.mjs → action.test.mjs} +147 -138
  6. package/dist/domain/paper-layout.d.ts +18 -6
  7. package/dist/domain/paper-layout.d.ts.map +1 -1
  8. package/dist/domain/paper-layout.js +44 -38
  9. package/dist/domain/paper-layout.js.map +1 -1
  10. package/dist/eslint-rules/papers.js +1 -1
  11. package/dist/folder-layout-hook.js +1 -1
  12. package/dist/latex-log.d.ts +1 -1
  13. package/dist/latex-log.js +1 -1
  14. package/dist/latex-loop.d.ts +1 -1
  15. package/dist/latex-loop.js +1 -1
  16. package/dist/lib/paper-config.d.ts +3 -3
  17. package/dist/lib/paper-config.js +3 -3
  18. package/docs/e2e.md +9 -9
  19. package/docs/install.md +11 -11
  20. package/docs/rules/paper/allowed-files-only.md +31 -28
  21. package/docs/testing.md +3 -4
  22. package/eslint-rules/{install-path-literals.harness.mjs → install-path-literals.test.mjs} +14 -13
  23. package/eslint-rules/{latex-language.harness.mjs → latex-language-rules.test.mjs} +61 -51
  24. package/eslint-rules/{paper-stages.harness.mjs → paper-stages-rule.test.mjs} +66 -69
  25. package/eslint-rules/{papers.harness.mjs → papers.test.mjs} +41 -30
  26. package/eslint-rules/papers.ts +1 -1
  27. package/eslint-rules/{pdf-last-page-balance.harness.mjs → pdf-last-page-balance.test.mjs} +27 -15
  28. package/eslint-rules/{temp-root-realpath.harness.mjs → temp-root-realpath.test.mjs} +24 -24
  29. package/eslint-rules/{tex-build.harness.mjs → tex-build.test.mjs} +292 -271
  30. package/eslint.config.mjs +15 -2
  31. package/fixtures/pdf-facts/README.md +1 -1
  32. package/fixtures/render-paper/build-clean.sh +1 -1
  33. package/fixtures/toolchain-mirror/install-tl +1 -1
  34. package/lib/{agent-cli-version.harness.mjs → agent-cli-version.test.mjs} +17 -18
  35. package/lib/{paper-config.harness.mjs → paper-config.test.mjs} +21 -20
  36. package/lib/paper-config.ts +3 -3
  37. package/lib/{skill-trigger-cases.harness.mjs → skill-trigger-cases-carrier.test.mjs} +78 -115
  38. package/package.json +3 -3
  39. package/presets/acm-acmsmall.jsonc +1 -1
  40. package/scripts/check-workflow.test.ts +368 -0
  41. package/scripts/check.ts +2 -2
  42. package/scripts/eslint-file-length.mjs +9 -9
  43. package/scripts/eslint-report-guard.mjs +1 -1
  44. package/scripts/eslint-report-guard.test.mjs +1 -1
  45. package/scripts/harness-api.test.ts +7 -46
  46. package/scripts/{rules-see-files.harness.mjs → rules-see-files-rule.test.mjs} +10 -6
  47. package/scripts/rules-see-files.mjs +1 -1
  48. package/skills/paper-pipeline/{paper-pipeline.harness.mjs → paper-pipeline.test.mjs} +45 -46
  49. package/skills/paper-pipeline/scripts/{consumer.harness.mjs → consumer-paths.test.mjs} +66 -59
  50. package/skills/paper-pipeline/scripts/consumer.mjs +3 -3
  51. package/skills/paper-pipeline/scripts/{extract-ref-facts.harness.mjs → extract-ref-facts-cli.test.mjs} +29 -31
  52. package/skills/paper-pipeline/scripts/fixtures/real-bib/refs.bib +1 -1
  53. package/skills/paper-pipeline/scripts/{generated-code.harness.mjs → generated-code-fixtures.test.mjs} +39 -46
  54. package/skills/render-paper/{extract-pdf-facts.harness.ts → extract-pdf-facts.test.ts} +20 -13
  55. package/skills/render-paper/{render-paper.harness.mjs → render-paper.test.mjs} +41 -40
  56. package/src/adapters/pdfjs/fill.test.ts +1 -1
  57. package/src/{build-engine.harness.mjs → build-engine-prepare.test.mjs} +98 -81
  58. package/src/{build.harness.mjs → build-fake-tex.test.mjs} +61 -28
  59. package/src/{cli.harness.mjs → cli-e2e.test.mjs} +109 -103
  60. package/src/cli.test.ts +2 -2
  61. package/src/{doctor.harness.mjs → doctor-install.test.mjs} +28 -29
  62. package/src/domain/paper-layout.test.ts +89 -49
  63. package/src/domain/paper-layout.ts +61 -42
  64. package/src/{engine.harness.mjs → engine.test.mjs} +120 -106
  65. package/src/facts-file.test.ts +1 -1
  66. package/src/folder-layout-hook.test.ts +1 -1
  67. package/src/folder-layout-hook.ts +1 -1
  68. package/src/folder-layout-rule.test.ts +1 -1
  69. package/src/{hooks-settings.harness.ts → hooks-settings.test.ts} +161 -146
  70. package/src/latex-log.test.ts +395 -0
  71. package/src/latex-log.ts +1 -1
  72. package/src/latex-loop.test.ts +553 -0
  73. package/src/latex-loop.ts +1 -1
  74. package/src/layout-docs.test.ts +47 -0
  75. package/src/{link-skills.harness.ts → link-skills-fs.test.ts} +26 -26
  76. package/src/{new-paper.harness.mjs → new-paper-scaffold.test.mjs} +31 -19
  77. package/src/{pdf-facts.harness.ts → pdf-facts-tables.test.ts} +28 -22
  78. package/src/{pdf-geometry.harness.ts → pdf-geometry.test.ts} +93 -75
  79. package/src/{rules-config.harness.ts → rules-config.test.ts} +41 -31
  80. package/src/{structure.harness.ts → structure.test.ts} +12 -10
  81. package/src/{tex-requirements.harness.ts → tex-requirements-tables.test.ts} +106 -85
  82. package/src/{toolchain.harness.mjs → toolchain-mirror.test.mjs} +204 -186
  83. package/scripts/check.harness.ts +0 -343
  84. package/scripts/harness-api.frozen.json +0 -41
  85. package/src/latex-log.harness.ts +0 -382
  86. package/src/latex-loop.harness.ts +0 -515
@@ -18,7 +18,10 @@ import {
18
18
  import { tmpdir } from "node:os";
19
19
  import { dirname, join } from "node:path";
20
20
  import { fileURLToPath } from "node:url";
21
- import { createChecker } from "../lib/check.ts";
21
+ import { expect, it, vi } from "vitest";
22
+
23
+ // Several tests here run real ESLint, spawn processes or walk the repository.
24
+ vi.setConfig({ testTimeout: 120_000 });
22
25
 
23
26
  const HERE = dirname(fileURLToPath(import.meta.url));
24
27
  const {
@@ -32,7 +35,11 @@ const {
32
35
  supportedPlatform,
33
36
  } = await import(join(HERE, "engine.ts"));
34
37
 
35
- const check = createChecker();
38
+ /** One soft assertion: a failed check does not stop the checks after it in the same test. */
39
+ const check = (label, cond, detail) =>
40
+ expect
41
+ .soft(cond, detail === undefined ? label : `${label}\n${detail}`)
42
+ .toBe(true);
36
43
 
37
44
  // ── 1. resolveEngine ────────────────────────────────────────────────────────────────────
38
45
  const tree = (label, missing = []) => ({ label, bin: `/${label}`, missing });
@@ -102,20 +109,22 @@ const ROWS = [
102
109
  { kind: "use-system", tree: COMPLETE_SYS },
103
110
  ],
104
111
  ];
105
- for (const [label, f, want] of ROWS) {
106
- const got = resolveEngine(f);
112
+ it("1. resolveEngine", () => {
113
+ for (const [label, f, want] of ROWS) {
114
+ const got = resolveEngine(f);
115
+ check(
116
+ `resolveEngine: ${label}`,
117
+ JSON.stringify(got) === JSON.stringify(want),
118
+ JSON.stringify(got),
119
+ );
120
+ }
107
121
  check(
108
- `resolveEngine: ${label}`,
109
- JSON.stringify(got) === JSON.stringify(want),
110
- JSON.stringify(got),
122
+ "supportedPlatform: linux and darwin, not win32",
123
+ supportedPlatform("linux") &&
124
+ supportedPlatform("darwin") &&
125
+ !supportedPlatform("win32"),
111
126
  );
112
- }
113
- check(
114
- "supportedPlatform: linux and darwin, not win32",
115
- supportedPlatform("linux") &&
116
- supportedPlatform("darwin") &&
117
- !supportedPlatform("win32"),
118
- );
127
+ });
119
128
 
120
129
  // ── 2. the fact readers ─────────────────────────────────────────────────────────────────
121
130
  const PKGS = {
@@ -123,47 +132,50 @@ const PKGS = {
123
132
  latex: ["latex.ltx", "article.cls"],
124
133
  libertine: ["libertine.sty"],
125
134
  };
126
- check(
127
- "missingPackages: matched by FILE NAME of each printed path, sorted",
128
- JSON.stringify(missingPackages(PKGS, "/t/tex/latex/acmart/acmart.cls\n")) ===
129
- '["latex","libertine"]',
130
- );
131
- // Guards: a package counts as present only when EVERY file that proves it resolves.
132
- check(
133
- "missingPackages: one proof of two missing is enough to count the package missing",
134
- missingPackages(
135
- { latex: ["latex.ltx", "article.cls"] },
136
- "/t/latex.ltx\n",
137
- ).includes("latex"),
138
- );
139
- check(
140
- "missingPackages: all present → none",
141
- missingPackages(
142
- PKGS,
143
- "/a/acmart.cls\n/b/latex.ltx\n/b/article.cls\n/c/libertine.sty\n",
144
- ).length === 0,
145
- );
146
- check(
147
- "missingTools: by executable in the bin directory",
148
- JSON.stringify(
149
- missingTools(
150
- { texcount: ["texcount"], checkcites: ["checkcites"] },
151
- "/bin",
152
- (p) => p === "/bin/texcount",
153
- ),
154
- ) === '["checkcites"]',
155
- );
156
- check(
157
- "whichOnPath: the first directory that has it; empty segments skipped",
158
- whichOnPath("pdflatex", ":/a:/b:/c", (p) =>
159
- ["/b/pdflatex", "/c/pdflatex"].includes(p),
160
- ) === "/b",
161
- );
162
- check(
163
- "whichOnPath: nowhere → null",
164
- whichOnPath("pdflatex", "/a:/b", () => false) === null,
165
- );
166
- {
135
+ it("2. the fact readers: missingPackages, missingTools, whichOnPath", () => {
136
+ check(
137
+ "missingPackages: matched by FILE NAME of each printed path, sorted",
138
+ JSON.stringify(
139
+ missingPackages(PKGS, "/t/tex/latex/acmart/acmart.cls\n"),
140
+ ) === '["latex","libertine"]',
141
+ );
142
+ // Guards: a package counts as present only when EVERY file that proves it resolves.
143
+ check(
144
+ "missingPackages: one proof of two missing is enough to count the package missing",
145
+ missingPackages(
146
+ { latex: ["latex.ltx", "article.cls"] },
147
+ "/t/latex.ltx\n",
148
+ ).includes("latex"),
149
+ );
150
+ check(
151
+ "missingPackages: all present → none",
152
+ missingPackages(
153
+ PKGS,
154
+ "/a/acmart.cls\n/b/latex.ltx\n/b/article.cls\n/c/libertine.sty\n",
155
+ ).length === 0,
156
+ );
157
+ check(
158
+ "missingTools: by executable in the bin directory",
159
+ JSON.stringify(
160
+ missingTools(
161
+ { texcount: ["texcount"], checkcites: ["checkcites"] },
162
+ "/bin",
163
+ (p) => p === "/bin/texcount",
164
+ ),
165
+ ) === '["checkcites"]',
166
+ );
167
+ check(
168
+ "whichOnPath: the first directory that has it; empty segments skipped",
169
+ whichOnPath("pdflatex", ":/a:/b:/c", (p) =>
170
+ ["/b/pdflatex", "/c/pdflatex"].includes(p),
171
+ ) === "/b",
172
+ );
173
+ check(
174
+ "whichOnPath: nowhere → null",
175
+ whichOnPath("pdflatex", "/a:/b", () => false) === null,
176
+ );
177
+ });
178
+ it("2. the fact readers: probeTree through a fake runner", () => {
167
179
  const calls = [];
168
180
  const run = (cmd, args) => {
169
181
  calls.push([cmd, args]);
@@ -181,20 +193,22 @@ check(
181
193
  "probeTree: kpsewhich's exit code is not the verdict — the printed paths are",
182
194
  JSON.stringify(missing) === '["latex","libertine"]',
183
195
  );
184
- }
196
+ });
185
197
  // Guards: "could not ask" must never read as "nothing missing" — a broken tree would be used.
186
- check(
187
- "🔴 probeTree: a kpsewhich that cannot start finds NOTHING — never 'all present'",
188
- JSON.stringify(
189
- probeTree("/none", PKGS, () => ({ error: new Error("ENOENT") })),
190
- ) === '["acmart","latex","libertine"]',
191
- );
198
+ it("2. the fact readers: a kpsewhich that cannot start finds nothing", () => {
199
+ check(
200
+ "🔴 probeTree: a kpsewhich that cannot start finds NOTHING — never 'all present'",
201
+ JSON.stringify(
202
+ probeTree("/none", PKGS, () => ({ error: new Error("ENOENT") })),
203
+ ) === '["acmart","latex","libertine"]',
204
+ );
205
+ });
192
206
 
193
207
  // ── 3. "installed" means a regular file that can be run — on a REAL filesystem ─────────────
194
208
  // 🔴 `existsSync` says yes to a directory and to a file without the execute bit; both then fail
195
209
  // to start, while `paperlint toolchain --check` reported the tree verified. Checked on disk, not
196
210
  // through an injected predicate, because the predicate is exactly what was wrong.
197
- {
211
+ it('3. "installed" means a regular file that can be run — on a REAL filesystem', () => {
198
212
  const bin = realpathSync(
199
213
  mkdtempSync(join(tmpdir(), "paperlint-engine-bin-")),
200
214
  );
@@ -246,7 +260,7 @@ check(
246
260
  } finally {
247
261
  rmSync(bin, { recursive: true, force: true });
248
262
  }
249
- }
263
+ });
250
264
 
251
265
  // ── missingDependencies: what an install that "continued anyway" left out ──────────────────
252
266
  // Real stdout of `tlmgr check depends` on a tree whose install-tl lost unicode-data to a mirror
@@ -256,7 +270,7 @@ const BROKEN_DEPENDS =
256
270
  "\f DEPENDS WITHOUT PACKAGES:\n" +
257
271
  "unicode-data in: collection-basic latex-bin luahbtex luatex\n" +
258
272
  "\f PACKAGES NOT IN ANY COLLECTION: acmart booktabs caption\n";
259
- {
273
+ it('missingDependencies: what an install that "continued anyway" left out', () => {
260
274
  const calls = [];
261
275
  const run = (cmd, args) => {
262
276
  calls.push([cmd, args]);
@@ -280,45 +294,45 @@ const BROKEN_DEPENDS =
280
294
  JSON.stringify(missing) === '["unicode-data"]',
281
295
  JSON.stringify(missing),
282
296
  );
283
- }
284
- check(
285
- "missingDependencies: packages outside any collection are not gaps",
286
- JSON.stringify(
287
- missingDependencies("/tl/bin", () => ({
288
- stdout: "\f PACKAGES NOT IN ANY COLLECTION: acmart booktabs\n",
289
- status: 2,
290
- })),
291
- ) === "[]",
292
- );
293
- check(
294
- "missingDependencies: a clean tree has none",
295
- JSON.stringify(
296
- missingDependencies("/tl/bin", () => ({ stdout: "", status: 0 })),
297
- ) === "[]",
298
- );
299
-
300
- check(
301
- "missingDependencies: a tlmgr that cannot start reports nothing (the tree is judged by probeTree alone)",
302
- JSON.stringify(
303
- missingDependencies("/tl/bin", () => ({ error: new Error("ENOENT") })),
304
- ) === "[]",
305
- );
306
- check(
307
- "missingDependencies: a section that runs to the end of the output, with no header after it",
308
- JSON.stringify(
309
- missingDependencies("/tl/bin", () => ({
310
- stdout:
311
- "\f DEPENDS WITHOUT PACKAGES:\nunicode-data in: latex-bin\nhyphen-base in: x",
312
- status: 2,
313
- })),
314
- ) === '["hyphen-base","unicode-data"]',
315
- );
316
- check(
317
- "a runner that returns no stdout at all: tlmgr lists nothing, kpsewhich finds nothing",
318
- JSON.stringify(missingDependencies("/tl/bin", () => ({ status: 0 }))) ===
319
- "[]" &&
320
- JSON.stringify(probeTree("/tl/bin", PKGS, () => ({ status: 0 }))) ===
321
- JSON.stringify(Object.keys(PKGS).sort()),
322
- );
297
+ });
298
+ it("missingDependencies: the other cases", () => {
299
+ check(
300
+ "missingDependencies: packages outside any collection are not gaps",
301
+ JSON.stringify(
302
+ missingDependencies("/tl/bin", () => ({
303
+ stdout: "\f PACKAGES NOT IN ANY COLLECTION: acmart booktabs\n",
304
+ status: 2,
305
+ })),
306
+ ) === "[]",
307
+ );
308
+ check(
309
+ "missingDependencies: a clean tree has none",
310
+ JSON.stringify(
311
+ missingDependencies("/tl/bin", () => ({ stdout: "", status: 0 })),
312
+ ) === "[]",
313
+ );
323
314
 
324
- console.log(`engine: ${check.count} checks passed`);
315
+ check(
316
+ "missingDependencies: a tlmgr that cannot start reports nothing (the tree is judged by probeTree alone)",
317
+ JSON.stringify(
318
+ missingDependencies("/tl/bin", () => ({ error: new Error("ENOENT") })),
319
+ ) === "[]",
320
+ );
321
+ check(
322
+ "missingDependencies: a section that runs to the end of the output, with no header after it",
323
+ JSON.stringify(
324
+ missingDependencies("/tl/bin", () => ({
325
+ stdout:
326
+ "\f DEPENDS WITHOUT PACKAGES:\nunicode-data in: latex-bin\nhyphen-base in: x",
327
+ status: 2,
328
+ })),
329
+ ) === '["hyphen-base","unicode-data"]',
330
+ );
331
+ check(
332
+ "a runner that returns no stdout at all: tlmgr lists nothing, kpsewhich finds nothing",
333
+ JSON.stringify(missingDependencies("/tl/bin", () => ({ status: 0 }))) ===
334
+ "[]" &&
335
+ JSON.stringify(probeTree("/tl/bin", PKGS, () => ({ status: 0 }))) ===
336
+ JSON.stringify(Object.keys(PKGS).sort()),
337
+ );
338
+ });
@@ -4,7 +4,7 @@
4
4
  * The document is assembled from hand-made measurements (pure), and `measurePaper` runs on
5
5
  * in-memory files with a FAKE pdf.js reader and a FAKE measurer, so each outcome — read failed, not
6
6
  * measured, measured — is chosen rather than hoped for. Reading real PDFs is
7
- * `pdf-facts.harness.ts`'s job; banal as the measurer is `adapters/banal/index.test.ts`, and the
7
+ * `pdf-facts-tables.test.ts`'s job; banal as the measurer is `adapters/banal/index.test.ts`, and the
8
8
  * real banal is `test/e2e/tex/banal.e2e.ts`.
9
9
  */
10
10
  import assert from "node:assert/strict";
@@ -75,7 +75,7 @@ describe("paper-folder-layout hook — denies a new stray entry", () => {
75
75
  },
76
76
  });
77
77
  expect(out?.hookSpecificOutput.permissionDecisionReason).toMatch(
78
- /^`PLAN\.md` is at the root of a paper folder.*\n<paper>\/\n/su,
78
+ /^`PLAN\.md` does not belong at a paper folder's root: move it to a section of PIPELINE-STATUS\.md[^\n]*$/u,
79
79
  );
80
80
  });
81
81
 
@@ -3,7 +3,7 @@
3
3
  * created, not at the next lint. PreToolUse on `Edit|Write|MultiEdit` (`plugin/hooks/hooks.json`):
4
4
  * when the file about to be written does not exist yet and would add an entry the layout does not
5
5
  * allow — at a paper folder's root, or at the top of its `repro/` — the call is denied, and the
6
- * reason is the rule's own message: where the entry goes, and the layout drawn. The agent writes it
6
+ * reason is the rule's own message: where the entry goes (for `repro/`, also its layout drawn). The agent writes it
7
7
  * where it belongs instead, in the same turn.
8
8
  *
9
9
  * ── WHAT IT NEVER BLOCKS ─────────────────────────────────────────────────────────
@@ -75,7 +75,7 @@ describe("paper/allowed-files-only — reports", () => {
75
75
  ),
76
76
  ).toEqual([
77
77
  expect.stringMatching(
78
- /^`archive\/` is at the root of a paper folder.* Where it goes: versions\/ for frozen PDFs/,
78
+ /^`archive\/` does not belong at a paper folder's root: move it to extra\//,
79
79
  ),
80
80
  ]);
81
81
  });