paperlint 20.2.0 → 20.4.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 (64) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/adapters/venue-corpus/index.d.ts +19 -3
  3. package/dist/adapters/venue-corpus/index.d.ts.map +1 -1
  4. package/dist/adapters/venue-corpus/index.js +36 -8
  5. package/dist/adapters/venue-corpus/index.js.map +1 -1
  6. package/dist/cli.d.ts +4 -3
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +42 -13
  9. package/dist/cli.js.map +1 -1
  10. package/dist/corpus-record-rule.d.ts +65 -0
  11. package/dist/corpus-record-rule.d.ts.map +1 -0
  12. package/dist/corpus-record-rule.js +85 -0
  13. package/dist/corpus-record-rule.js.map +1 -0
  14. package/dist/domain/corpus-record.d.ts +51 -0
  15. package/dist/domain/corpus-record.d.ts.map +1 -0
  16. package/dist/domain/corpus-record.js +119 -0
  17. package/dist/domain/corpus-record.js.map +1 -0
  18. package/dist/domain/venue-corpus.d.ts +36 -5
  19. package/dist/domain/venue-corpus.d.ts.map +1 -1
  20. package/dist/domain/venue-corpus.js +20 -0
  21. package/dist/domain/venue-corpus.js.map +1 -1
  22. package/dist/paper-files.d.ts +10 -3
  23. package/dist/paper-files.d.ts.map +1 -1
  24. package/dist/paper-files.js +17 -2
  25. package/dist/paper-files.js.map +1 -1
  26. package/dist/papers-roots.d.ts +6 -0
  27. package/dist/papers-roots.d.ts.map +1 -1
  28. package/dist/papers-roots.js +14 -0
  29. package/dist/papers-roots.js.map +1 -1
  30. package/docs/design/venue-corpus.md +62 -40
  31. package/docs/layout.md +2 -2
  32. package/docs/rules/corpus/record.md +122 -0
  33. package/docs/rules.md +1 -0
  34. package/docs/venues.md +35 -20
  35. package/eslint.config.mjs +1 -0
  36. package/package.json +2 -1
  37. package/scripts/eslint-file-length.mjs +3 -3
  38. package/skills/study-accepted-papers/SKILL.md +14 -8
  39. package/skills/study-accepted-papers/SKILL.md.spec.ts +13 -7
  40. package/skills/study-accepted-papers/papers.schema.json +50 -2
  41. package/skills/study-accepted-papers/scripts/corpus-licences-core.js +2 -2
  42. package/skills/study-accepted-papers/scripts/corpus-licences-core.ts +2 -1
  43. package/skills/study-accepted-papers/scripts/corpus-licences.js +39 -10
  44. package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +5 -1
  45. package/src/adapters/venue-corpus/index.test.ts +81 -55
  46. package/src/adapters/venue-corpus/index.ts +42 -9
  47. package/src/adapters/venue-corpus/schema.test.ts +47 -0
  48. package/src/cli-e2e.test.mjs +2 -2
  49. package/src/cli.test.ts +1 -1
  50. package/src/cli.ts +57 -13
  51. package/src/corpus-record-rule.test.ts +229 -0
  52. package/src/corpus-record-rule.ts +175 -0
  53. package/src/domain/corpus-record.test.ts +163 -0
  54. package/src/domain/corpus-record.ts +210 -0
  55. package/src/domain/venue-corpus.test.ts +85 -0
  56. package/src/domain/venue-corpus.ts +59 -5
  57. package/src/paper-files.test.ts +13 -4
  58. package/src/paper-files.ts +23 -2
  59. package/src/paper-settings-commands.test.ts +2 -2
  60. package/src/papers-roots.test.ts +34 -1
  61. package/src/papers-roots.ts +15 -0
  62. package/src/rule-cases.test.ts +15 -0
  63. package/src/settled-paper.test.ts +1 -1
  64. package/src/unowned-file.test.ts +1 -1
@@ -4,7 +4,12 @@
4
4
  */
5
5
  import assert from "node:assert/strict";
6
6
  import { test } from "vitest";
7
- import { papersRoots, segmentsUnder, toPaths } from "./papers-roots.ts";
7
+ import {
8
+ inCorpus,
9
+ papersRoots,
10
+ segmentsUnder,
11
+ toPaths,
12
+ } from "./papers-roots.ts";
8
13
 
9
14
  test("a papers directory given as a string or as a list normalises to a list; anything else to none", () => {
10
15
  assert.deepEqual(
@@ -54,3 +59,31 @@ test("a path is placed under the first directory that holds it, by its segments"
54
59
  [["x", "paper.tex"], ["y"], null, null, null, ["..draft", "paper.tex"]],
55
60
  );
56
61
  });
62
+
63
+ test("a folder is in a venue corpus when it is `<root>/venues/<venue>/` or below it", () => {
64
+ const roots = ["/p/papers"];
65
+ assert.deepEqual(
66
+ [
67
+ "/p/papers/venues/agent",
68
+ "/p/papers/venues/agent/sources/x",
69
+ "/p/papers/venues",
70
+ "/p/papers/agent",
71
+ "/p/elsewhere/venues/agent",
72
+ ].map((d) => inCorpus(d, roots)),
73
+ [true, true, false, false, false],
74
+ );
75
+ });
76
+
77
+ test("🔴 a corpus under any of overlapping roots is a corpus, whichever root is listed first", () => {
78
+ // Guards: `papersDir: [".", "papers"]` — the corpus under the second root must still be excluded
79
+ // from the paper rules, not read through the first root as `papers/venues/agent`.
80
+ const dir = "/project/papers/venues/agent";
81
+ assert.deepEqual(
82
+ [
83
+ inCorpus(dir, ["/project", "/project/papers"]),
84
+ inCorpus(dir, ["/project/papers", "/project"]),
85
+ inCorpus("/project/papers/agent", ["/project", "/project/papers"]),
86
+ ],
87
+ [true, true, false],
88
+ );
89
+ });
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import { isAbsolute, relative, resolve, sep } from "node:path";
13
13
  import { DEFAULT_PAPERS_ROOT } from "#lib/paper-config";
14
+ import { CORPORA_DIR } from "./domain/corpus-record.ts";
14
15
 
15
16
  /** The papers directory field of the settings, read by its one declared name; the default when absent. */
16
17
  export function papersDirOf(opts: { readonly papersDir?: unknown }): unknown {
@@ -54,3 +55,17 @@ export function segmentsUnder(
54
55
  );
55
56
  return below === undefined ? null : below.split(sep);
56
57
  }
58
+
59
+ /**
60
+ * Whether the absolute folder `dir` is a venue corpus of one of `roots`, or inside one:
61
+ * `<root>/venues/<venue>/` and below. A paper found there is an accepted paper's source kept in the
62
+ * corpus, not one of the project's papers (#215), so no paper rule judges it.
63
+ */
64
+ export function inCorpus(dir: string, roots: readonly string[]): boolean {
65
+ // Each root on its own: roots may overlap (`.` and `papers`), and the first that holds `dir` need
66
+ // not be the one whose `venues/` it is in.
67
+ return roots.some((root) => {
68
+ const [first, venue] = segmentsUnder(dir, [root]) ?? [];
69
+ return first === CORPORA_DIR && venue !== undefined;
70
+ });
71
+ }
@@ -42,6 +42,8 @@ const fixture = (p: string): string =>
42
42
  readFileSync(join(ROOT, "fixtures", p), "utf8");
43
43
 
44
44
  const P = "papers/p";
45
+ const CORPUS_RECORD = "papers/venues/agent/papers.json";
46
+ const EMPTY_RECORD = '{"venue":"agent","editions":[],"papers":[],"rebuild":[]}';
45
47
  const STATUS = "---\nstages: []\n---\n# PIPELINE-STATUS\n";
46
48
  const tex = (body: string, cls = "\\documentclass{article}"): string =>
47
49
  `${cls}\n\\begin{document}\n${body}\n\\end{document}\n`;
@@ -1280,6 +1282,19 @@ const CASES: Readonly<Record<string, RuleCases>> = {
1280
1282
  [`${P}/extra/PLAN.md`]: "# plan\n",
1281
1283
  }),
1282
1284
  },
1285
+ // A venue corpus storing a PDF its papers.json lists no paper for; silent while it stores nothing.
1286
+ "corpus/record": {
1287
+ reports: {
1288
+ tree: paper(tex("x"), {
1289
+ [CORPUS_RECORD]: EMPTY_RECORD,
1290
+ "papers/venues/agent/pdf/a.pdf": "",
1291
+ }),
1292
+ file: CORPUS_RECORD,
1293
+ severity: 2,
1294
+ line: 1,
1295
+ },
1296
+ silent: paper(tex("x"), { [CORPUS_RECORD]: EMPTY_RECORD }),
1297
+ },
1283
1298
  // A loose script at the top of repro/: it belongs in repro/tools/.
1284
1299
  "repro/allowed-files-only": {
1285
1300
  reports: {
@@ -60,7 +60,7 @@ function paper(
60
60
 
61
61
  /** The blocks the paper's stage adds. */
62
62
  function stageBlocks(dir: string) {
63
- const r = paperRuleBlocks([dir]);
63
+ const r = paperRuleBlocks([dir], []);
64
64
  assert.ok(r.ok, r.ok ? "" : r.error);
65
65
  return r.value.stage;
66
66
  }
@@ -88,7 +88,7 @@ describe("any other unowned file keeps the general refusal, without the glob it
88
88
  const r = await lint(dir, "papers/a/repro/x.js");
89
89
  expect(r.code).toBe(2);
90
90
  expect(r.err).toBe(
91
- "papers/a/repro/x.js is not a file paperlint lints — it lints **/PIPELINE-STATUS.md, **/reviews/*.md, **/paper.tex, **/siblings/*.md, and the .tex files a built paper.tex includes",
91
+ "papers/a/repro/x.js is not a file paperlint lints — it lints **/PIPELINE-STATUS.md, **/venues/*/papers.json, **/reviews/*.md, **/paper.tex, **/siblings/*.md, and the .tex files a built paper.tex includes",
92
92
  );
93
93
  });
94
94