paperlint 20.1.2 → 20.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CLAUDE.md +5 -1
  3. package/dist/adapters/venue-corpus/index.d.ts +345 -0
  4. package/dist/adapters/venue-corpus/index.d.ts.map +1 -0
  5. package/dist/adapters/venue-corpus/index.js +205 -0
  6. package/dist/adapters/venue-corpus/index.js.map +1 -0
  7. package/dist/domain/licence.d.ts +51 -0
  8. package/dist/domain/licence.d.ts.map +1 -0
  9. package/dist/domain/licence.js +61 -0
  10. package/dist/domain/licence.js.map +1 -0
  11. package/dist/domain/venue-corpus.d.ts +120 -0
  12. package/dist/domain/venue-corpus.d.ts.map +1 -0
  13. package/dist/domain/venue-corpus.js +13 -0
  14. package/dist/domain/venue-corpus.js.map +1 -0
  15. package/dist/eslint-rules/CLAUDE.md.spec.d.ts.map +1 -1
  16. package/dist/eslint-rules/CLAUDE.md.spec.js +1 -0
  17. package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
  18. package/dist/ports/venue-corpus-codec.d.ts +11 -0
  19. package/dist/ports/venue-corpus-codec.d.ts.map +1 -0
  20. package/dist/ports/venue-corpus-codec.js +2 -0
  21. package/dist/ports/venue-corpus-codec.js.map +1 -0
  22. package/dist/skill-chunks/chunk-5KCU4WTN.js +108 -0
  23. package/dist/skill-chunks/{chunk-X4VKG4KT.js → chunk-6YEM4VDI.js} +11 -9
  24. package/dist/skill-chunks/{chunk-L3NJUJUP.js → chunk-CXAGKT44.js} +5 -3
  25. package/dist/skill-chunks/{chunk-6NU6CXUS.js → chunk-J5XYPERO.js} +12 -72
  26. package/dist/skill-chunks/{chunk-IREAROCV.js → chunk-Z5YMDZYW.js} +4 -0
  27. package/dist/skills/study-accepted-papers/scripts/corpus-licences-core.d.ts +54 -0
  28. package/dist/skills/study-accepted-papers/scripts/corpus-licences.d.ts +2 -0
  29. package/docs/design/venue-corpus.md +250 -0
  30. package/docs/venues.md +144 -21
  31. package/eslint-rules/CLAUDE.md +5 -1
  32. package/eslint-rules/CLAUDE.md.spec.ts +3 -0
  33. package/package.json +2 -1
  34. package/scripts/bundle-skills.ts +1 -0
  35. package/scripts/venue-corpus-schema.test.ts +39 -0
  36. package/scripts/venue-corpus-schema.ts +17 -0
  37. package/skills/argument-arc/scripts/headings.js +6 -4
  38. package/skills/cold-read-diff/scripts/cold-read.js +6 -4
  39. package/skills/paper-pipeline/scripts/extract-ref-facts.js +6 -5
  40. package/skills/pc-panel-review/scripts/prior-reviews.js +7 -5
  41. package/skills/study-accepted-papers/SKILL.md +28 -2
  42. package/skills/study-accepted-papers/SKILL.md.spec.ts +27 -1
  43. package/skills/study-accepted-papers/papers.schema.json +427 -0
  44. package/skills/study-accepted-papers/scripts/corpus-licences-core.js +180 -0
  45. package/skills/study-accepted-papers/scripts/corpus-licences-core.ts +302 -0
  46. package/skills/study-accepted-papers/scripts/corpus-licences.js +383 -0
  47. package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +485 -0
  48. package/skills/study-accepted-papers/scripts/corpus-licences.ts +27 -0
  49. package/skills/verify-citations/scripts/bib-authors.js +6 -5
  50. package/skills/verify-citations/scripts/verify-cites.js +6 -5
  51. package/src/adapters/venue-corpus/index.test.ts +279 -0
  52. package/src/adapters/venue-corpus/index.ts +286 -0
  53. package/src/domain/licence.test.ts +122 -0
  54. package/src/domain/licence.ts +95 -0
  55. package/src/domain/venue-corpus.ts +130 -0
  56. package/src/ports/venue-corpus-codec.ts +11 -0
@@ -0,0 +1,383 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __plCreateRequire } from "node:module";
3
+ import { fileURLToPath as __plFileURLToPath } from "node:url";
4
+ import { dirname as __plDirname } from "node:path";
5
+ const require = __plCreateRequire(import.meta.url);
6
+ const __filename = __plFileURLToPath(import.meta.url);
7
+ const __dirname = __plDirname(__filename);
8
+ import {
9
+ CONFIG_FILE,
10
+ DEFAULT_PAPERS_ROOT,
11
+ PAPERS_DIR_FIELD
12
+ } from "../../../dist/skill-chunks/chunk-Z5YMDZYW.js";
13
+ import {
14
+ callerPath,
15
+ nodeFiles,
16
+ spawnProcess
17
+ } from "../../../dist/skill-chunks/chunk-5KCU4WTN.js";
18
+ import {
19
+ external_exports
20
+ } from "../../../dist/skill-chunks/chunk-4MHEJ6FR.js";
21
+ import "../../../dist/skill-chunks/chunk-PJ4KNV4J.js";
22
+
23
+ // src/domain/licence.ts
24
+ var STORED_KINDS = ["text", "pdf"];
25
+ var NOASSERTION = "NOASSERTION";
26
+ var ND = {
27
+ no: "ND permits reproduction in unmodified form; whether an extracted text is an adaptation is unsettled"
28
+ };
29
+ var ARXIV = {
30
+ no: 'it grants arXiv alone the right to distribute: "We are thus unable to grant others the right to distribute arXiv articles"'
31
+ };
32
+ var PUBLISHER = {
33
+ no: "the publisher grants no right to third parties"
34
+ };
35
+ var TABLE = /* @__PURE__ */ new Map([
36
+ ["CC0-1.0", { text: "yes", pdf: "yes" }],
37
+ ["CC-BY-4.0", { text: "yes", pdf: "yes" }],
38
+ ["CC-BY-SA-4.0", { text: "yes", pdf: "yes" }],
39
+ ["CC-BY-NC-4.0", { text: "non-commercial", pdf: "non-commercial" }],
40
+ ["CC-BY-NC-SA-4.0", { text: "non-commercial", pdf: "non-commercial" }],
41
+ ["CC-BY-ND-4.0", { text: ND, pdf: "yes" }],
42
+ ["CC-BY-NC-ND-4.0", { text: ND, pdf: "non-commercial" }],
43
+ ["LicenseRef-arxiv-nonexclusive-1.0", { text: ARXIV, pdf: ARXIV }],
44
+ ["LicenseRef-publisher", { text: PUBLISHER, pdf: PUBLISHER }]
45
+ ]);
46
+ var isLicenceId = (id) => /^(?:LicenseRef-[A-Za-z0-9.-]+|[A-Za-z0-9][A-Za-z0-9.-]*\+?)$/u.test(id);
47
+ function permits(id, kind, settings) {
48
+ if (id === NOASSERTION) return { kind: "not-read" };
49
+ const row = TABLE.get(id);
50
+ if (row === void 0) return { kind: "unlisted", id };
51
+ const grant = row[kind];
52
+ if (grant === "yes") return { kind: "permitted" };
53
+ if (grant === "non-commercial")
54
+ return settings.nonCommercial ? { kind: "permitted" } : { kind: "non-commercial-only" };
55
+ return { kind: "forbidden", why: grant.no };
56
+ }
57
+
58
+ // src/domain/venue-corpus.ts
59
+ var CORPUS_RECORD = "papers.json";
60
+ var KNOWN_VERSIONS = ["published", "accepted", "preprint"];
61
+ var PAPER_ID_KINDS = ["doi", "arxiv", "dblp", "s2", "url"];
62
+ var KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u;
63
+
64
+ // src/adapters/venue-corpus/index.ts
65
+ var words = external_exports.string().min(1);
66
+ var date = external_exports.iso.date();
67
+ var webUrl = external_exports.url({
68
+ protocol: /^https?$/u,
69
+ error: "an http or https address"
70
+ });
71
+ var repeats = (values) => values.flatMap((v, i) => {
72
+ const first = values.indexOf(v);
73
+ return first === i ? [] : [[i, first]];
74
+ });
75
+ var licenceId = external_exports.string().refine(isLicenceId, "an SPDX license id or a LicenseRef-");
76
+ var notRead = external_exports.strictObject({ id: external_exports.literal(NOASSERTION) });
77
+ var licence = external_exports.strictObject({
78
+ id: licenceId,
79
+ read_from: webUrl.optional(),
80
+ read_on: date.optional()
81
+ }).transform((l, ctx) => {
82
+ const fields = ["read_from", "read_on"];
83
+ const noneRead = l.id === NOASSERTION;
84
+ const wrong = fields.filter((f) => l[f] === void 0 !== noneRead);
85
+ wrong.forEach((f) => {
86
+ ctx.addIssue({
87
+ code: "custom",
88
+ path: [f],
89
+ message: noneRead ? "NOASSERTION means the licence was not read" : `a licence other than NOASSERTION names ${f === "read_from" ? "where" : "when"} it was read`
90
+ });
91
+ });
92
+ return l.read_from === void 0 || l.read_on === void 0 ? { id: NOASSERTION } : { id: l.id, read_from: l.read_from, read_on: l.read_on };
93
+ });
94
+ var storage = {
95
+ stored: external_exports.array(external_exports.enum(STORED_KINDS)),
96
+ fetched_from: webUrl.optional()
97
+ };
98
+ var stores = (c, ctx) => {
99
+ repeats(c.stored).forEach(([i]) => {
100
+ ctx.addIssue({
101
+ code: "custom",
102
+ path: ["stored"],
103
+ message: `"${String(c.stored[i])}" is listed twice`
104
+ });
105
+ });
106
+ if (c.stored.length > 0 && c.fetched_from === void 0)
107
+ ctx.addIssue({
108
+ code: "custom",
109
+ path: ["fetched_from"],
110
+ message: "a copy that stores a file names where it was fetched from"
111
+ });
112
+ };
113
+ var copy = external_exports.discriminatedUnion("version", [
114
+ external_exports.strictObject({
115
+ version: external_exports.enum(KNOWN_VERSIONS),
116
+ url: webUrl,
117
+ licence,
118
+ ...storage
119
+ }).superRefine(stores),
120
+ external_exports.strictObject({
121
+ version: external_exports.literal("unknown"),
122
+ licence: notRead,
123
+ ...storage
124
+ }).superRefine(stores)
125
+ ]);
126
+ var ids = external_exports.strictObject({
127
+ doi: words.optional(),
128
+ arxiv: words.optional(),
129
+ dblp: words.optional(),
130
+ s2: words.optional(),
131
+ url: webUrl.optional()
132
+ }).refine(
133
+ (i) => Object.values(i).some((v) => v !== void 0),
134
+ `at least one of ${PAPER_ID_KINDS.join(", ")}`
135
+ );
136
+ var paperFields = {
137
+ key: external_exports.string().regex(KEY_PATTERN, "a letter or digit, then letters, digits, '_' or '-'"),
138
+ title: words,
139
+ authors: external_exports.array(words).optional(),
140
+ abstract: external_exports.string().nullable().optional(),
141
+ ids,
142
+ copies: external_exports.array(copy)
143
+ };
144
+ var year = external_exports.number().int().positive();
145
+ var paper = external_exports.discriminatedUnion("group", [
146
+ external_exports.looseObject({
147
+ ...paperFields,
148
+ group: external_exports.enum(["accepted", "award"]),
149
+ edition: year
150
+ }),
151
+ external_exports.looseObject({
152
+ ...paperFields,
153
+ group: external_exports.literal("sister"),
154
+ venue: words,
155
+ year,
156
+ listed_from: webUrl
157
+ })
158
+ ]);
159
+ var edition = external_exports.strictObject({
160
+ edition: year,
161
+ listed_from: webUrl,
162
+ read_on: date,
163
+ accepted: external_exports.number().int().nonnegative().optional()
164
+ });
165
+ var consistent = (r, ctx) => {
166
+ const years = r.editions.map((e) => e.edition);
167
+ repeats(years).forEach(([i]) => {
168
+ ctx.addIssue({
169
+ code: "custom",
170
+ path: ["editions", i, "edition"],
171
+ message: `${String(years[i])} is listed twice`
172
+ });
173
+ });
174
+ const keys = r.papers.map((p) => p.key);
175
+ repeats(keys).forEach(([i, first]) => {
176
+ ctx.addIssue({
177
+ code: "custom",
178
+ path: ["papers", i, "key"],
179
+ message: `"${String(keys[i])}" is the key of papers.${String(first)} too`
180
+ });
181
+ });
182
+ r.papers.forEach((p, i) => {
183
+ if (p.group !== "sister" && !years.includes(p.edition))
184
+ ctx.addIssue({
185
+ code: "custom",
186
+ path: ["papers", i, "edition"],
187
+ message: `${String(p.edition)} is not one of editions[].edition (${years.join(", ")})`
188
+ });
189
+ });
190
+ };
191
+ var record = external_exports.strictObject({
192
+ venue: words,
193
+ editions: external_exports.array(edition),
194
+ papers: external_exports.array(paper)
195
+ }).superRefine(consistent);
196
+ function jsonOf(text) {
197
+ try {
198
+ return JSON.parse(text);
199
+ } catch {
200
+ return void 0;
201
+ }
202
+ }
203
+ function parseVenueCorpus(text) {
204
+ const json = jsonOf(text);
205
+ if (json === void 0)
206
+ return { ok: false, why: `${CORPUS_RECORD} is not JSON` };
207
+ const parsed = record.safeParse(json);
208
+ if (parsed.success) return { ok: true, corpus: parsed.data };
209
+ const reasons = parsed.error.issues.map(
210
+ (i) => `${i.path.length === 0 ? "(top)" : i.path.join(".")}: ${i.message}`
211
+ );
212
+ return { ok: false, why: `${CORPUS_RECORD}: ${reasons.join("; ")}` };
213
+ }
214
+ var venueCorpusCodec = { parse: parseVenueCorpus };
215
+
216
+ // skills/study-accepted-papers/scripts/corpus-licences-core.ts
217
+ import { dirname, join } from "node:path";
218
+
219
+ // src/papers-roots.ts
220
+ import { isAbsolute, relative, resolve, sep } from "node:path";
221
+ function papersDirOf(opts) {
222
+ const declared = opts.papersDir;
223
+ return declared === void 0 ? DEFAULT_PAPERS_ROOT : declared;
224
+ }
225
+ function toPaths(papers) {
226
+ if (typeof papers === "string") return papers.trim() ? [papers.trim()] : [];
227
+ if (Array.isArray(papers))
228
+ return papers.filter(
229
+ (x) => typeof x === "string" && x.trim() !== ""
230
+ );
231
+ return [];
232
+ }
233
+ var papersRoots = (cfg) => toPaths(papersDirOf(cfg.opts)).map((rel) => resolve(cfg.root, rel));
234
+
235
+ // skills/study-accepted-papers/scripts/corpus-licences-core.ts
236
+ var isRefused = (j) => j.permission.kind !== "permitted";
237
+ var keptOf = (judged) => judged.map((j) => j.copy).find(
238
+ (c, i) => judged[i]?.permission.kind === "permitted" && c.version !== "unknown"
239
+ );
240
+ var refusalsOf = (judged) => judged.filter(isRefused).map((j) => ({
241
+ version: j.copy.version,
242
+ licence: j.copy.licence.id,
243
+ permission: j.permission
244
+ }));
245
+ function verdictOf(paper2, stored, settings) {
246
+ const judged = paper2.copies.map((copy2) => ({
247
+ copy: copy2,
248
+ permission: permits(copy2.licence.id, stored, settings)
249
+ }));
250
+ const kept = keptOf(judged);
251
+ const { key } = paper2;
252
+ return kept === void 0 ? {
253
+ key,
254
+ stored,
255
+ outcome: "none",
256
+ refusals: refusalsOf(judged)
257
+ } : {
258
+ key,
259
+ stored,
260
+ outcome: "keep",
261
+ version: kept.version,
262
+ licence: kept.licence.id,
263
+ url: kept.url
264
+ };
265
+ }
266
+ var verdicts = (corpus, settings) => corpus.papers.flatMap(
267
+ (p) => STORED_KINDS.map((kind) => verdictOf(p, kind, settings))
268
+ );
269
+ function reason(r) {
270
+ switch (r.permission.kind) {
271
+ case "forbidden":
272
+ return `${r.licence}: ${r.permission.why}`;
273
+ case "non-commercial-only":
274
+ return `${r.licence} permits it only in a project declared non-commercial`;
275
+ case "not-read":
276
+ return "its licence was not read (NOASSERTION)";
277
+ case "unlisted":
278
+ return `${r.permission.id} is not in the licence table, so it permits nothing`;
279
+ }
280
+ }
281
+ function line(v) {
282
+ const what = v.outcome === "keep" ? `keep the ${v.version} copy (${v.licence}), ${v.url}` : v.refusals.length === 0 ? "none: no copy recorded" : `none: ${v.refusals.map((r) => `${r.version}: ${reason(r)}`).join("; ")}`;
283
+ return `${v.key} ${v.stored}: ${what}`;
284
+ }
285
+ var listing = (all) => all.length === 0 ? `${CORPUS_RECORD} holds no paper
286
+ ` : `${all.map(line).join("\n")}
287
+ `;
288
+ function gitTopLevel(git2, path, cwd) {
289
+ const r = git2.run({
290
+ file: "git",
291
+ args: ["rev-parse", "--show-toplevel"],
292
+ env: { PATH: path ?? "" },
293
+ timeoutMs: 1e4,
294
+ cwd: callerPath(cwd)
295
+ });
296
+ const top = r.kind === "exited" && r.status === 0 ? r.stdout.trim() : "";
297
+ return top === "" ? null : top;
298
+ }
299
+ var UNDECLARED = { nonCommercial: false };
300
+ var VENUE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/u;
301
+ var USAGE = "usage: node corpus-licences.js <venue>\n";
302
+ function settingsOf(files, root) {
303
+ const file = join(root, CONFIG_FILE);
304
+ const bytes = files.readBytes(callerPath(file));
305
+ if (bytes === null) return { ok: true, opts: {} };
306
+ const parsed = jsonOf2(new TextDecoder().decode(bytes));
307
+ if (parsed === void 0) return { ok: false, why: `${file} is not JSON` };
308
+ return {
309
+ ok: true,
310
+ opts: isObject(parsed) ? { [PAPERS_DIR_FIELD]: parsed[PAPERS_DIR_FIELD] } : {}
311
+ };
312
+ }
313
+ var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
314
+ function jsonOf2(text) {
315
+ try {
316
+ return JSON.parse(text);
317
+ } catch {
318
+ return void 0;
319
+ }
320
+ }
321
+ function recordOf(deps, venue) {
322
+ const root = deps.projectRoot(deps.cwd);
323
+ if (root === null)
324
+ return {
325
+ ok: false,
326
+ why: `${deps.cwd} is not inside a git repository: run it in the project`
327
+ };
328
+ const settings = settingsOf(deps.files, root);
329
+ if (!settings.ok) return settings;
330
+ const looked = papersRoots({ opts: settings.opts, root }).map(
331
+ (papers) => join(papers, "venues", venue, CORPUS_RECORD)
332
+ );
333
+ const found = looked.filter((f) => deps.files.isFile(callerPath(f)));
334
+ const [only] = found;
335
+ if (only !== void 0 && found.length === 1) return { ok: true, file: only };
336
+ return {
337
+ ok: false,
338
+ why: found.length === 0 ? `no ${CORPUS_RECORD} for venue "${venue}": looked in ${looked.map((f) => dirname(f)).join(", ")}; write the record first` : `venue "${venue}" is in more than one papers folder: ${found.map((f) => dirname(f)).join(", ")}`
339
+ };
340
+ }
341
+ function main(argv, deps, { out, err }) {
342
+ const [venue, ...rest] = argv;
343
+ if (venue === void 0 || rest.length > 0 || !VENUE.test(venue)) {
344
+ err(USAGE);
345
+ return 2;
346
+ }
347
+ const at = recordOf(deps, venue);
348
+ if (!at.ok) {
349
+ err(`corpus-licences: ${at.why}
350
+ `);
351
+ return 1;
352
+ }
353
+ const bytes = deps.files.readBytes(callerPath(at.file));
354
+ if (bytes === null) {
355
+ err(`corpus-licences: ${at.file} could not be read
356
+ `);
357
+ return 1;
358
+ }
359
+ const parsed = deps.codec.parse(new TextDecoder().decode(bytes));
360
+ if (!parsed.ok) {
361
+ err(`corpus-licences: ${parsed.why}
362
+ `);
363
+ return 1;
364
+ }
365
+ out(listing(verdicts(parsed.corpus, UNDECLARED)));
366
+ return 0;
367
+ }
368
+
369
+ // skills/study-accepted-papers/scripts/corpus-licences.ts
370
+ var git = spawnProcess();
371
+ process.exitCode = main(
372
+ process.argv.slice(2),
373
+ {
374
+ files: nodeFiles,
375
+ codec: venueCorpusCodec,
376
+ projectRoot: (cwd) => gitTopLevel(git, process.env["PATH"], cwd),
377
+ cwd: process.cwd()
378
+ },
379
+ {
380
+ out: (s) => process.stdout.write(s),
381
+ err: (s) => process.stderr.write(s)
382
+ }
383
+ );