paperlint 18.5.0 → 18.7.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 +3 -3
- package/CONTRIBUTING.md +5 -2
- package/README.md +6 -6
- package/dist/adapters/clack/index.d.ts +3 -0
- package/dist/adapters/clack/index.d.ts.map +1 -0
- package/dist/adapters/clack/index.js +3 -0
- package/dist/adapters/clack/index.js.map +1 -0
- package/dist/adapters/clack/prompts.io.d.ts +8 -0
- package/dist/adapters/clack/prompts.io.d.ts.map +1 -0
- package/dist/adapters/clack/prompts.io.js +20 -0
- package/dist/adapters/clack/prompts.io.js.map +1 -0
- package/dist/adapters/hotcrp/portal.io.d.ts.map +1 -1
- package/dist/adapters/hotcrp/portal.io.js +1 -0
- package/dist/adapters/hotcrp/portal.io.js.map +1 -1
- package/dist/adapters/hotcrp/response.d.ts.map +1 -1
- package/dist/adapters/hotcrp/response.js +15 -0
- package/dist/adapters/hotcrp/response.js.map +1 -1
- package/dist/adapters/package-manager/index.d.ts +4 -0
- package/dist/adapters/package-manager/index.d.ts.map +1 -0
- package/dist/adapters/package-manager/index.js +4 -0
- package/dist/adapters/package-manager/index.js.map +1 -0
- package/dist/adapters/package-manager/install.io.d.ts +3 -0
- package/dist/adapters/package-manager/install.io.d.ts.map +1 -0
- package/dist/adapters/package-manager/install.io.js +23 -0
- package/dist/adapters/package-manager/install.io.js.map +1 -0
- package/dist/adapters/package-manager/manager.d.ts +13 -0
- package/dist/adapters/package-manager/manager.d.ts.map +1 -0
- package/dist/adapters/package-manager/manager.js +22 -0
- package/dist/adapters/package-manager/manager.js.map +1 -0
- package/dist/adapters/study-registry/index.d.ts +2 -2
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +47 -9
- package/dist/cli.js.map +1 -1
- package/dist/domain/submission.d.ts +4 -0
- package/dist/domain/submission.d.ts.map +1 -1
- package/dist/domain/submission.js.map +1 -1
- package/dist/init.d.ts +38 -15
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +99 -39
- package/dist/init.js.map +1 -1
- package/dist/ports/project-install.d.ts +19 -0
- package/dist/ports/project-install.d.ts.map +1 -0
- package/dist/ports/project-install.js +2 -0
- package/dist/ports/project-install.js.map +1 -0
- package/dist/ports/prompts.d.ts +31 -0
- package/dist/ports/prompts.d.ts.map +1 -0
- package/dist/ports/prompts.js +2 -0
- package/dist/ports/prompts.js.map +1 -0
- package/dist/self-install.d.ts +65 -0
- package/dist/self-install.d.ts.map +1 -0
- package/dist/self-install.js +145 -0
- package/dist/self-install.js.map +1 -0
- package/dist/skill-chunks/chunk-65X5HVIJ.js +26462 -0
- package/dist/skill-chunks/chunk-6NU6CXUS.js +258 -0
- package/dist/skill-chunks/chunk-GRSXIWYF.js +352 -0
- package/dist/skill-chunks/chunk-IREAROCV.js +84 -0
- package/dist/skill-chunks/chunk-KWK6RT4T.js +24267 -0
- package/dist/skill-chunks/chunk-NPQVDEE4.js +19681 -0
- package/dist/skill-chunks/chunk-PJ4KNV4J.js +45 -0
- package/dist/skill-chunks/dist-UPCJMLBM.js +385 -0
- package/dist/skill-chunks/pdfjs-LUMEFOH2.js +39518 -0
- package/dist/submission.d.ts +19 -2
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +121 -17
- package/dist/submission.js.map +1 -1
- package/docs/e2e.md +10 -0
- package/docs/install.md +27 -16
- package/docs/prior-art/README.md +2 -0
- package/docs/prior-art/one-command-install.md +33 -0
- package/docs/prior-art/prompt-libraries.md +32 -0
- package/docs/submission.md +19 -4
- package/eslint.config.mjs +1 -0
- package/lib/skill-checks.mjs +17 -9
- package/lib/skill-checks.test.mjs +28 -15
- package/lib/skill-corpus.mjs +5 -2
- package/package.json +5 -3
- package/scripts/bundle-skills.test.ts +226 -0
- package/scripts/bundle-skills.ts +304 -0
- package/skills/argument-arc/SKILL.md +2 -2
- package/skills/argument-arc/SKILL.md.spec.ts +1 -1
- package/skills/argument-arc/scripts/headings.js +57 -13
- package/skills/build-label-page/scripts/label-page.js +2005 -93
- package/skills/cold-read-diff/scripts/cold-read.js +221 -14
- package/skills/label-agent-runs/scripts/labels.js +272 -348
- package/skills/paper-pipeline/scripts/extract-ref-facts.js +304 -0
- package/skills/pc-panel-review/scripts/prior-reviews.js +7244 -12
- package/skills/run-agent-grid/scripts/grid-guard.js +562 -627
- package/skills/verify-citations/SKILL.md +9 -9
- package/skills/verify-citations/SKILL.md.spec.ts +8 -8
- package/skills/verify-citations/scripts/bib-authors.js +228 -0
- package/skills/verify-citations/scripts/verify-cites.js +816 -0
- package/src/adapters/clack/index.ts +2 -0
- package/src/adapters/clack/prompts.io.ts +35 -0
- package/src/adapters/clack/prompts.test.ts +58 -0
- package/src/adapters/hotcrp/portal.io.ts +1 -0
- package/src/adapters/hotcrp/portal.test.ts +43 -2
- package/src/adapters/hotcrp/response.ts +21 -0
- package/src/adapters/package-manager/index.test.ts +67 -0
- package/src/adapters/package-manager/index.ts +3 -0
- package/src/adapters/package-manager/install.io.ts +27 -0
- package/src/adapters/package-manager/manager.ts +33 -0
- package/src/cli.harness.mjs +41 -26
- package/src/cli.test.ts +93 -2
- package/src/cli.ts +80 -7
- package/src/domain/submission.ts +4 -0
- package/src/init.test.ts +138 -27
- package/src/init.ts +128 -72
- package/src/ports/project-install.ts +18 -0
- package/src/ports/prompts.ts +27 -0
- package/src/self-install.test.ts +267 -0
- package/src/self-install.ts +224 -0
- package/src/submission-fields-run.test.ts +1 -0
- package/src/submission-prior-reviews.test.ts +9 -1
- package/src/submission-show.test.ts +81 -0
- package/src/submission-update.test.ts +164 -6
- package/src/submission.ts +208 -24
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
import { expect, test } from "vitest";
|
|
3
3
|
import { memoryFiles } from "./adapters/memory/index.ts";
|
|
4
4
|
import { err, ok } from "./domain/result.ts";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
type PortalFailure,
|
|
7
|
+
type SubmissionView,
|
|
8
|
+
type UpdateOutcome,
|
|
9
|
+
} from "./domain/submission.ts";
|
|
6
10
|
import {
|
|
7
11
|
PAPER,
|
|
8
12
|
SITE,
|
|
@@ -14,6 +18,10 @@ import {
|
|
|
14
18
|
run,
|
|
15
19
|
NO_ERRORS,
|
|
16
20
|
facts,
|
|
21
|
+
DEFAULT_TEX,
|
|
22
|
+
ABSTRACT_TEX,
|
|
23
|
+
VIEW,
|
|
24
|
+
WANT,
|
|
17
25
|
} from "../test/submission-fixtures.ts";
|
|
18
26
|
|
|
19
27
|
test("update: a dry run by default — the paper's PDF sent, nothing saved, exit 0", async () => {
|
|
@@ -25,6 +33,7 @@ test("update: a dry run by default — the paper's PDF sent, nothing saved, exit
|
|
|
25
33
|
7,
|
|
26
34
|
{
|
|
27
35
|
pdf: { name: "paper.pdf", bytes: PDF },
|
|
36
|
+
title: null,
|
|
28
37
|
abstract: null,
|
|
29
38
|
submit: false,
|
|
30
39
|
fields: {},
|
|
@@ -35,6 +44,8 @@ test("update: a dry run by default — the paper's PDF sent, nothing saved, exit
|
|
|
35
44
|
expect(r.out).toStrictEqual([
|
|
36
45
|
CHECK("papers/p/paper.pdf", "the call for papers, https://example.org/cfp"),
|
|
37
46
|
NO_ERRORS,
|
|
47
|
+
NOT_CHECKED,
|
|
48
|
+
NO_ABSTRACT,
|
|
38
49
|
"dry run — the portal checked the change and kept nothing; --save sends it for real",
|
|
39
50
|
"HTTP 200",
|
|
40
51
|
"valid yes",
|
|
@@ -64,6 +75,7 @@ test("update --save --submit --abstract --pdf: all of it sent, and said to be sa
|
|
|
64
75
|
7,
|
|
65
76
|
{
|
|
66
77
|
pdf: { name: "other.pdf", bytes: PDF },
|
|
78
|
+
title: null,
|
|
67
79
|
abstract: "The abstract.",
|
|
68
80
|
submit: true,
|
|
69
81
|
fields: {},
|
|
@@ -72,9 +84,11 @@ test("update --save --submit --abstract --pdf: all of it sent, and said to be sa
|
|
|
72
84
|
],
|
|
73
85
|
]);
|
|
74
86
|
// Guards: the PDF that is sent is the one named, and --save is told to check it too.
|
|
75
|
-
expect(r.out.slice(0,
|
|
87
|
+
expect(r.out.slice(0, 5)).toStrictEqual([
|
|
76
88
|
CHECK("other.pdf", "the call for papers, https://example.org/cfp"),
|
|
77
89
|
NO_ERRORS,
|
|
90
|
+
NOT_CHECKED,
|
|
91
|
+
"abstract sends abs.txt (2 words), from --abstract",
|
|
78
92
|
"saved",
|
|
79
93
|
]);
|
|
80
94
|
});
|
|
@@ -113,7 +127,7 @@ test("update: valid:false, or a non-2xx status, exits 1 with the portal's messag
|
|
|
113
127
|
{ portal: fakePortal({ update: invalid }) },
|
|
114
128
|
);
|
|
115
129
|
expect(r1.code).toBe(1);
|
|
116
|
-
expect(r1.out.slice(
|
|
130
|
+
expect(r1.out.slice(6)).toStrictEqual([
|
|
117
131
|
"valid NO",
|
|
118
132
|
"changes —",
|
|
119
133
|
`local PDF papers/p/paper.pdf sha2-${HEX}`,
|
|
@@ -154,7 +168,7 @@ test("update --save that the portal withheld says so", async () => {
|
|
|
154
168
|
{ sub: "update", save: true },
|
|
155
169
|
{ portal: fakePortal({ update: withheld }) },
|
|
156
170
|
);
|
|
157
|
-
expect(r.out[
|
|
171
|
+
expect(r.out[4]).toBe("SAVE WITHHELD by the portal — nothing changed");
|
|
158
172
|
});
|
|
159
173
|
|
|
160
174
|
test("update: no PDF to send, or no abstract file, is refused before the portal is asked", async () => {
|
|
@@ -169,6 +183,14 @@ test("update: no PDF to send, or no abstract file, is refused before the portal
|
|
|
169
183
|
expect(r2.errs).toStrictEqual(["--abstract: no file at nope.txt"]);
|
|
170
184
|
});
|
|
171
185
|
|
|
186
|
+
/** `update`'s title line for the made-up paper, which has no paper.tex and no PDF Title. */
|
|
187
|
+
const NOT_CHECKED =
|
|
188
|
+
"title not checked — no \\title in paper.tex, and the PDF names no Title — add \\title{…}, or \\hypersetup{pdftitle={…}}, and rebuild";
|
|
189
|
+
|
|
190
|
+
/** `update`'s abstract line for the made-up paper, which has no paper.tex. */
|
|
191
|
+
const NO_ABSTRACT =
|
|
192
|
+
"abstract not checked — no paper.tex to read the abstract from — give the abstract with --abstract <file>, a plain-text file";
|
|
193
|
+
|
|
172
194
|
// ── the venue check before a send (paperlint#264) ─────────────────────────────────────
|
|
173
195
|
|
|
174
196
|
/** A paper of kind `short` (6 body pages) at a venue over AIDC, not blind, built 8 body pages long. */
|
|
@@ -197,11 +219,13 @@ const LINT_BLOCK = (level: "error" | "warning", text: string): string[] => [
|
|
|
197
219
|
test("update over the page limit: the venue rules' findings on that PDF, as lint prints them, before the portal is asked; a dry run still runs", async () => {
|
|
198
220
|
const r = await run({ sub: "update" }, { files: OVER });
|
|
199
221
|
expect(r.code).toBe(0);
|
|
200
|
-
expect(r.out.slice(1,
|
|
222
|
+
expect(r.out.slice(1, 9)).toStrictEqual([
|
|
201
223
|
...LINT_BLOCK(
|
|
202
224
|
"error",
|
|
203
225
|
"body pages (up to the references on page 9): 8, over the limit 6 for venue/short — a desk reject; cut the text format/page-limit",
|
|
204
226
|
),
|
|
227
|
+
NOT_CHECKED,
|
|
228
|
+
NO_ABSTRACT,
|
|
205
229
|
"dry run — the portal checked the change and kept nothing; --save sends it for real",
|
|
206
230
|
]);
|
|
207
231
|
expect(r.seen[0]?.calls).toHaveLength(1);
|
|
@@ -209,7 +233,7 @@ test("update over the page limit: the venue rules' findings on that PDF, as lint
|
|
|
209
233
|
|
|
210
234
|
test("update --save over the limit: the same findings, and the send goes ahead — the person decides on them, not the command", async () => {
|
|
211
235
|
const r = await run({ sub: "update", save: true }, { files: OVER });
|
|
212
|
-
expect([r.code, r.errs, r.out[2], r.out[
|
|
236
|
+
expect([r.code, r.errs, r.out[2], r.out[8]]).toStrictEqual([
|
|
213
237
|
0,
|
|
214
238
|
[],
|
|
215
239
|
`${PAPER}/paper.tex`,
|
|
@@ -314,3 +338,137 @@ test("porting skips the venue rules, not the freshness: --save with facts about
|
|
|
314
338
|
);
|
|
315
339
|
expect([unbuilt.code, unbuilt.errs]).toStrictEqual([2, [REFUSAL]]);
|
|
316
340
|
});
|
|
341
|
+
|
|
342
|
+
/** The made-up paper with its source, so `update` has a title and an abstract to compare with the portal's. */
|
|
343
|
+
const titled = (tex: string = DEFAULT_TEX) =>
|
|
344
|
+
files({ extra: { [`${PAPER}/paper.tex`]: tex } });
|
|
345
|
+
|
|
346
|
+
/** The portal holding the paper's own title and abstract, spaced differently. */
|
|
347
|
+
const holding = (more: Partial<SubmissionView> = {}) =>
|
|
348
|
+
fakePortal({
|
|
349
|
+
show: ok({
|
|
350
|
+
...VIEW,
|
|
351
|
+
title: " Agents That Lie ",
|
|
352
|
+
abstract: `${WANT.abstract.replaceAll(" ", "\n")}\n`,
|
|
353
|
+
...more,
|
|
354
|
+
}),
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
/** What `update` sends of the made-up paper with nothing else asked. */
|
|
358
|
+
const SENT = (text: { title: string | null; abstract: string | null }) => [
|
|
359
|
+
"update",
|
|
360
|
+
7,
|
|
361
|
+
{
|
|
362
|
+
pdf: { name: "paper.pdf", bytes: PDF },
|
|
363
|
+
...text,
|
|
364
|
+
submit: false,
|
|
365
|
+
fields: {},
|
|
366
|
+
},
|
|
367
|
+
{ save: false },
|
|
368
|
+
];
|
|
369
|
+
|
|
370
|
+
test("🔴 update: a \\title and an abstract that differ from the portal's are sent, and said, in the dry run", async () => {
|
|
371
|
+
const r = await run({ sub: "update" }, { files: titled() });
|
|
372
|
+
expect(r.code).toBe(0);
|
|
373
|
+
expect(r.seen[0]?.calls).toStrictEqual([
|
|
374
|
+
["show", 7],
|
|
375
|
+
SENT({ title: "Agents That Lie", abstract: WANT.abstract }),
|
|
376
|
+
]);
|
|
377
|
+
expect(r.out.slice(0, 5)).toStrictEqual([
|
|
378
|
+
CHECK("papers/p/paper.pdf", "the call for papers, https://example.org/cfp"),
|
|
379
|
+
NO_ERRORS,
|
|
380
|
+
"title sends «Agents That Lie» — the portal has «A Fake Title»",
|
|
381
|
+
"abstract sends the paper's (17 words) — the portal has another (4 words)",
|
|
382
|
+
"dry run — the portal checked the change and kept nothing; --save sends it for real",
|
|
383
|
+
]);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
test("update: a \\title and an abstract the portal already holds are not sent", async () => {
|
|
387
|
+
const r = await run(
|
|
388
|
+
{ sub: "update" },
|
|
389
|
+
{ files: titled(), portal: holding() },
|
|
390
|
+
);
|
|
391
|
+
expect(r.code).toBe(0);
|
|
392
|
+
expect(r.seen[0]?.calls[1]).toStrictEqual(
|
|
393
|
+
SENT({ title: null, abstract: null }),
|
|
394
|
+
);
|
|
395
|
+
expect(r.out.slice(2, 4)).toStrictEqual([
|
|
396
|
+
"title unchanged — the portal holds «Agents That Lie»",
|
|
397
|
+
"abstract unchanged — the portal holds the paper's (17 words)",
|
|
398
|
+
]);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
test("update: a portal with no title and no abstract gets the paper's, said as none", async () => {
|
|
402
|
+
const none = holding({ title: null, abstract: null });
|
|
403
|
+
const r = await run({ sub: "update" }, { files: titled(), portal: none });
|
|
404
|
+
expect(r.out.slice(2, 4)).toStrictEqual([
|
|
405
|
+
"title sends «Agents That Lie» — the portal has none",
|
|
406
|
+
"abstract sends the paper's (17 words) — the portal has none",
|
|
407
|
+
]);
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
test("update: neither readable — both said, nothing asked of the portal for them, and the PDF still sent", async () => {
|
|
411
|
+
const r = await run({ sub: "update" });
|
|
412
|
+
expect(r.code).toBe(0);
|
|
413
|
+
expect(r.seen[0]?.calls).toStrictEqual([
|
|
414
|
+
SENT({ title: null, abstract: null }),
|
|
415
|
+
]);
|
|
416
|
+
expect(r.out.slice(2, 4)).toStrictEqual([NOT_CHECKED, NO_ABSTRACT]);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
test("update: one of the two readable is enough to ask the portal — an abstract with no \\title, a \\title with no abstract", async () => {
|
|
420
|
+
const abstractOnly = `\\documentclass{article}\n\\newcommand{\\ours}{TestLie}\n\\begin{document}\n${ABSTRACT_TEX}\\end{document}\n`;
|
|
421
|
+
const r1 = await run(
|
|
422
|
+
{ sub: "update" },
|
|
423
|
+
{ files: titled(abstractOnly), portal: holding() },
|
|
424
|
+
);
|
|
425
|
+
expect(r1.seen[0]?.calls).toStrictEqual([
|
|
426
|
+
["show", 7],
|
|
427
|
+
SENT({ title: null, abstract: null }),
|
|
428
|
+
]);
|
|
429
|
+
const titleOnly =
|
|
430
|
+
"\\documentclass{article}\n\\title{Agents That Lie}\n\\begin{document}\\end{document}\n";
|
|
431
|
+
const r2 = await run(
|
|
432
|
+
{ sub: "update" },
|
|
433
|
+
{ files: titled(titleOnly), portal: holding() },
|
|
434
|
+
);
|
|
435
|
+
expect(r2.seen[0]?.calls).toStrictEqual([
|
|
436
|
+
["show", 7],
|
|
437
|
+
SENT({ title: null, abstract: null }),
|
|
438
|
+
]);
|
|
439
|
+
expect(r2.out[3]).toBe(
|
|
440
|
+
"abstract not checked — paper.tex has no \\begin{abstract}…\\end{abstract} — give the abstract with --abstract <file>, a plain-text file",
|
|
441
|
+
);
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
test("update --abstract: the file is sent whatever the portal holds, and said", async () => {
|
|
445
|
+
const fs = files({
|
|
446
|
+
extra: {
|
|
447
|
+
[`${PAPER}/paper.tex`]: DEFAULT_TEX,
|
|
448
|
+
"/w/abs.txt": "Two words.\n",
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
const r = await run(
|
|
452
|
+
{ sub: "update", abstract: "abs.txt" },
|
|
453
|
+
{ files: fs, portal: holding() },
|
|
454
|
+
);
|
|
455
|
+
expect(r.seen[0]?.calls[1]).toStrictEqual(
|
|
456
|
+
SENT({ title: null, abstract: "Two words." }),
|
|
457
|
+
);
|
|
458
|
+
expect(r.out[3]).toBe(
|
|
459
|
+
"abstract sends abs.txt (2 words), from --abstract",
|
|
460
|
+
);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
test("update: the portal refusing the read exits 1 and sends nothing", async () => {
|
|
464
|
+
const refused = fakePortal({
|
|
465
|
+
show: err<PortalFailure>({
|
|
466
|
+
kind: "refused",
|
|
467
|
+
httpStatus: 401,
|
|
468
|
+
messages: [{ message: "Missing credentials", field: null, status: 2 }],
|
|
469
|
+
}),
|
|
470
|
+
});
|
|
471
|
+
const r = await run({ sub: "update" }, { files: titled(), portal: refused });
|
|
472
|
+
expect(r.code).toBe(1);
|
|
473
|
+
expect(r.seen[0]?.calls).toStrictEqual([["show", 7]]);
|
|
474
|
+
});
|
package/src/submission.ts
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
* adapter per portal kind does the talking (`src/adapters/hotcrp/`).
|
|
9
9
|
*
|
|
10
10
|
* show status, id, title, paper type, topics, abstract length, the PDF the portal holds — and
|
|
11
|
-
* whether it is the local `paper.pdf`, by sha256
|
|
12
|
-
*
|
|
11
|
+
* whether it is the local `paper.pdf`, by sha256; the paper's title, abstract and authors
|
|
12
|
+
* where they differ
|
|
13
|
+
* update send the PDF, the paper's title and abstract each when the portal holds another (or
|
|
14
|
+
* `--abstract`'s file), "submitted" if asked. A DRY RUN unless `--save`:
|
|
13
15
|
* the portal checks the change and keeps nothing
|
|
14
16
|
* topics the topics the portal offers, against the ones the venue preset records
|
|
15
17
|
*
|
|
@@ -26,6 +28,7 @@
|
|
|
26
28
|
* 🔴 THE TOKEN IS AN INPUT, AND ONLY AN INPUT. It comes from the environment (the root reads it), is
|
|
27
29
|
* handed to the adapter, and never appears in anything printed here.
|
|
28
30
|
*/
|
|
31
|
+
import { zip } from "remeda";
|
|
29
32
|
import { venueCycleOf } from "./domain/cycle.ts";
|
|
30
33
|
import { basename, join, resolve } from "node:path";
|
|
31
34
|
import { absolutePath } from "./domain/paths.ts";
|
|
@@ -164,8 +167,8 @@ export interface SubmissionArgs {
|
|
|
164
167
|
/** `--pdf <file>`, relative to `cwd`; null: the paper's own PDF. */
|
|
165
168
|
readonly pdf: string | null;
|
|
166
169
|
/**
|
|
167
|
-
* `--abstract <file>`, relative to `cwd`; null: `update`
|
|
168
|
-
* it
|
|
170
|
+
* `--abstract <file>`, relative to `cwd`; null: `new` and `update` read the abstract from the
|
|
171
|
+
* paper's source, and `update` sends it only when the portal holds another.
|
|
169
172
|
*/
|
|
170
173
|
readonly abstract: string | null;
|
|
171
174
|
readonly submit: boolean;
|
|
@@ -372,19 +375,70 @@ export function deadlineLine(d: InForce): string {
|
|
|
372
375
|
return `deadline ${d.what} ${set}${also}`;
|
|
373
376
|
}
|
|
374
377
|
|
|
378
|
+
/** A text the paper sets, said when the portal holds another; nothing when they match or it is unread. */
|
|
379
|
+
const notThePortals = (
|
|
380
|
+
label: string,
|
|
381
|
+
paper: string | null,
|
|
382
|
+
portal: string | null,
|
|
383
|
+
shown: (text: string) => string,
|
|
384
|
+
): readonly string[] =>
|
|
385
|
+
paper === null || sameText(paper, portal)
|
|
386
|
+
? []
|
|
387
|
+
: [
|
|
388
|
+
`${label} ${shown(paper)} — NOT the portal's; \`paperlint submission update\` sends it`,
|
|
389
|
+
];
|
|
390
|
+
|
|
391
|
+
const words = (text: string): string => `${String(wordCount(text))} words`;
|
|
392
|
+
|
|
393
|
+
const authorText = (a: Author): string =>
|
|
394
|
+
`${a.name} <${a.email}>${a.affiliation === null ? "" : `, ${a.affiliation}`}`;
|
|
395
|
+
|
|
396
|
+
/** One author on both sides: the email in any case, the name in any spacing, the affiliation. Pure. */
|
|
397
|
+
const sameAuthor = ([a, b]: readonly [Author, Author]): boolean =>
|
|
398
|
+
a.email.toLowerCase() === b.email.toLowerCase() &&
|
|
399
|
+
sameText(a.name, b.name) &&
|
|
400
|
+
(a.affiliation ?? "") === (b.affiliation ?? "");
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* The paper's authors (`paperlint.json`) said when the portal records others; nothing when either
|
|
404
|
+
* side names none. `update` never changes them: that is the site's, and the line says so. Pure.
|
|
405
|
+
*/
|
|
406
|
+
function authorsLines(
|
|
407
|
+
paper: readonly Author[] | null,
|
|
408
|
+
portal: readonly Author[] | null,
|
|
409
|
+
): readonly string[] {
|
|
410
|
+
if (paper === null || portal === null) return [];
|
|
411
|
+
const same =
|
|
412
|
+
paper.length === portal.length && zip(paper, portal).every(sameAuthor);
|
|
413
|
+
return same
|
|
414
|
+
? []
|
|
415
|
+
: [
|
|
416
|
+
`paper authors ${paper.map(authorText).join("; ")} — NOT the portal's (${portal.map(authorText).join("; ")}); \`paperlint submission update\` does not change the authors: change them on the site`,
|
|
417
|
+
];
|
|
418
|
+
}
|
|
419
|
+
|
|
375
420
|
/** `show`'s report. Pure. */
|
|
376
421
|
export function showLines(
|
|
377
422
|
t: SubmissionTarget,
|
|
378
423
|
view: SubmissionView,
|
|
379
|
-
local: {
|
|
424
|
+
local: {
|
|
425
|
+
readonly shown: string;
|
|
426
|
+
readonly sha256: Sha256 | null;
|
|
427
|
+
/** The paper's own title and abstract; null when paperlint cannot read one. */
|
|
428
|
+
readonly title: string | null;
|
|
429
|
+
readonly abstract: string | null;
|
|
430
|
+
},
|
|
380
431
|
): readonly string[] {
|
|
381
432
|
return [
|
|
382
433
|
`submission ${String(view.id)} on ${t.portal.url} (${t.portal.kind})`,
|
|
383
434
|
`status ${view.status}${view.submittedAt === null ? "" : `, submitted ${iso(view.submittedAt)}`}`,
|
|
384
435
|
`title ${view.title ?? "—"}`,
|
|
436
|
+
...notThePortals("paper title ", local.title, view.title, (x) => x),
|
|
385
437
|
`paper type ${view.paperType ?? "—"}`,
|
|
386
438
|
`topics ${view.topics.length ? view.topics.join("; ") : "—"}`,
|
|
387
|
-
`abstract ${view.abstract === null ? "—" :
|
|
439
|
+
`abstract ${view.abstract === null ? "—" : words(view.abstract)}`,
|
|
440
|
+
...notThePortals("paper abstract", local.abstract, view.abstract, words),
|
|
441
|
+
...authorsLines(t.authors, view.authors),
|
|
388
442
|
pdfLine(view),
|
|
389
443
|
`local PDF ${local.shown} ${local.sha256 === null ? "(missing)" : `sha2-${local.sha256}`}`,
|
|
390
444
|
matchLine(view, local.sha256),
|
|
@@ -489,9 +543,12 @@ async function runShow(
|
|
|
489
543
|
const view = await portal.show(t.id);
|
|
490
544
|
if (!view.ok) return failed(view.error, deps);
|
|
491
545
|
const bytes = bytesAt(deps.files, pdfPath);
|
|
546
|
+
const text = paperText(t.paperDir, bytes, deps);
|
|
492
547
|
const local = {
|
|
493
548
|
shown: shownPath(deps.cwd, pdfPath),
|
|
494
549
|
sha256: bytes === null ? null : sha256Hex(bytes),
|
|
550
|
+
title: text.title.ok ? text.title.value : null,
|
|
551
|
+
abstract: text.abstract.ok ? text.abstract.value : null,
|
|
495
552
|
};
|
|
496
553
|
// With `cycles`, the frozen versions beside the portal's copy: which is under review, which is history.
|
|
497
554
|
const versions = versionLines(t.paperDir, deps);
|
|
@@ -517,15 +574,15 @@ function abstractOf(
|
|
|
517
574
|
: ok(new TextDecoder().decode(bytes).trim());
|
|
518
575
|
}
|
|
519
576
|
|
|
520
|
-
/** What `update` sends: the PDF's bytes, the abstract's text, whether to mark it submitted, the fields. */
|
|
577
|
+
/** What `update` sends: the PDF's bytes, the title, the abstract's text, whether to mark it submitted, the fields. */
|
|
521
578
|
const changeOf = (
|
|
522
579
|
a: SubmissionArgs & { readonly pdfPath: string },
|
|
523
580
|
bytes: Uint8Array,
|
|
524
|
-
abstract: string | null,
|
|
581
|
+
text: { readonly title: string | null; readonly abstract: string | null },
|
|
525
582
|
fields: FieldValues,
|
|
526
583
|
) => ({
|
|
527
584
|
pdf: { name: basename(a.pdfPath), bytes },
|
|
528
|
-
|
|
585
|
+
...text,
|
|
529
586
|
submit: a.submit,
|
|
530
587
|
fields,
|
|
531
588
|
});
|
|
@@ -619,7 +676,7 @@ const VENUE_RULES = "venue rules at their default options";
|
|
|
619
676
|
const REBUILD_REFUSAL =
|
|
620
677
|
"refused: no build facts describe this PDF (none, unreadable, or of other bytes), so the venue rules did not see it — rebuild (`paperlint build`), run the dry run again, and read its venue check; nothing was sent";
|
|
621
678
|
|
|
622
|
-
/** `update`: send the PDF
|
|
679
|
+
/** `update`: send the PDF, a changed title and abstract, and "submitted" when asked; a dry run unless saving. */
|
|
623
680
|
async function runUpdate(
|
|
624
681
|
t: SubmissionTarget & { readonly id: number },
|
|
625
682
|
portal: SubmissionPortal,
|
|
@@ -641,8 +698,8 @@ async function runUpdate(
|
|
|
641
698
|
if (refused) return 2;
|
|
642
699
|
const plan = planFor(t, a.save, deps);
|
|
643
700
|
if (!plan.ok) return (deps.err(plan.error), 2);
|
|
644
|
-
const
|
|
645
|
-
const r = await
|
|
701
|
+
const sent = { a, bytes, abstract: abstract.value };
|
|
702
|
+
const r = await sendChange(t, portal, sent, deps);
|
|
646
703
|
if (!r.ok) return failed(r.error, deps);
|
|
647
704
|
return afterUpdate(t, r.value, sentOf(a, { shown, bytes }, plan.value), deps);
|
|
648
705
|
}
|
|
@@ -654,6 +711,118 @@ const sentOf = (
|
|
|
654
711
|
plan: FreezePlan | null,
|
|
655
712
|
) => ({ ...file, save: a.save, submit: a.submit, plan });
|
|
656
713
|
|
|
714
|
+
/** Two texts that differ only in spacing are one text. Pure. */
|
|
715
|
+
const sameText = (paper: string, portal: string | null): boolean =>
|
|
716
|
+
portal !== null &&
|
|
717
|
+
paper.replace(/\s+/g, " ").trim() === portal.replace(/\s+/g, " ").trim();
|
|
718
|
+
|
|
719
|
+
/** One text `update` may send: the text (null: none), and the line saying what happens to it. */
|
|
720
|
+
interface TextChange {
|
|
721
|
+
readonly send: string | null;
|
|
722
|
+
readonly line: string;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/** How a text is named in `update`'s line: its label, the paper's text, and the portal's when it differs. */
|
|
726
|
+
interface Shown {
|
|
727
|
+
readonly label: string;
|
|
728
|
+
readonly paper: (text: string) => string;
|
|
729
|
+
readonly portal: (text: string) => string;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
const TITLE: Shown = {
|
|
733
|
+
label: "title ",
|
|
734
|
+
paper: (x) => `«${x}»`,
|
|
735
|
+
portal: (x) => `«${x}»`,
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
const ABSTRACT: Shown = {
|
|
739
|
+
label: "abstract ",
|
|
740
|
+
paper: (x) => `the paper's (${words(x)})`,
|
|
741
|
+
portal: (x) => `another (${words(x)})`,
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
/** What `update` does about one text the paper sets: sends it when the portal holds another. Pure. */
|
|
745
|
+
export function textChange(
|
|
746
|
+
shown: Shown,
|
|
747
|
+
paper: Result<string, string>,
|
|
748
|
+
portal: string | null,
|
|
749
|
+
): TextChange {
|
|
750
|
+
if (!paper.ok)
|
|
751
|
+
return { send: null, line: `${shown.label}not checked — ${paper.error}` };
|
|
752
|
+
return sameText(paper.value, portal)
|
|
753
|
+
? {
|
|
754
|
+
send: null,
|
|
755
|
+
line: `${shown.label}unchanged — the portal holds ${shown.paper(paper.value)}`,
|
|
756
|
+
}
|
|
757
|
+
: {
|
|
758
|
+
send: paper.value,
|
|
759
|
+
line: `${shown.label}sends ${shown.paper(paper.value)} — the portal has ${portal === null ? "none" : shown.portal(portal)}`,
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/** What `update` sends: the PDF and its name, `--abstract`'s text (null: the paper's is compared). */
|
|
764
|
+
interface Sent {
|
|
765
|
+
readonly a: SubmissionArgs & { readonly pdfPath: string };
|
|
766
|
+
readonly bytes: Uint8Array;
|
|
767
|
+
readonly abstract: string | null;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/** `--abstract`'s text, sent whatever the portal holds, and said. Pure. */
|
|
771
|
+
const fromFile = (sent: Sent, abstract: string): TextChange => ({
|
|
772
|
+
send: abstract,
|
|
773
|
+
line: `${ABSTRACT.label}sends ${String(sent.a.abstract)} (${words(abstract)}), from --abstract`,
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* The title and abstract `update` sends: the paper's, each when the portal holds another (#619);
|
|
778
|
+
* `--abstract`'s file whatever it holds. The portal is read once, and only when there is something
|
|
779
|
+
* of the paper's to compare; a failed read stops the update.
|
|
780
|
+
*/
|
|
781
|
+
async function textsToSend(
|
|
782
|
+
t: SubmissionTarget & { readonly id: number },
|
|
783
|
+
portal: SubmissionPortal,
|
|
784
|
+
sent: Sent,
|
|
785
|
+
deps: RunDeps,
|
|
786
|
+
): Promise<
|
|
787
|
+
Result<
|
|
788
|
+
{ readonly title: TextChange; readonly abstract: TextChange },
|
|
789
|
+
PortalFailure
|
|
790
|
+
>
|
|
791
|
+
> {
|
|
792
|
+
const text = paperText(t.paperDir, sent.bytes, deps);
|
|
793
|
+
const read = text.title.ok || (sent.abstract === null && text.abstract.ok);
|
|
794
|
+
const view = read ? await portal.show(t.id) : ok(null);
|
|
795
|
+
if (!view.ok) return err(view.error);
|
|
796
|
+
const held = view.value;
|
|
797
|
+
return ok({
|
|
798
|
+
title: textChange(TITLE, text.title, held === null ? null : held.title),
|
|
799
|
+
abstract:
|
|
800
|
+
sent.abstract === null
|
|
801
|
+
? textChange(
|
|
802
|
+
ABSTRACT,
|
|
803
|
+
text.abstract,
|
|
804
|
+
held === null ? null : held.abstract,
|
|
805
|
+
)
|
|
806
|
+
: fromFile(sent, sent.abstract),
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/** The change sent, its title and abstract lines printed first: the portal's answer, or why there is none. */
|
|
811
|
+
async function sendChange(
|
|
812
|
+
t: SubmissionTarget & { readonly id: number },
|
|
813
|
+
portal: SubmissionPortal,
|
|
814
|
+
sent: Sent,
|
|
815
|
+
deps: RunDeps,
|
|
816
|
+
): Promise<Result<UpdateOutcome, PortalFailure>> {
|
|
817
|
+
const texts = await textsToSend(t, portal, sent, deps);
|
|
818
|
+
if (!texts.ok) return err(texts.error);
|
|
819
|
+
const { title, abstract } = texts.value;
|
|
820
|
+
logAll([title.line, abstract.line], deps);
|
|
821
|
+
const text = { title: title.send, abstract: abstract.send };
|
|
822
|
+
const change = changeOf(sent.a, sent.bytes, text, t.fields);
|
|
823
|
+
return portal.update(t.id, change, { save: sent.a.save });
|
|
824
|
+
}
|
|
825
|
+
|
|
657
826
|
/** The portal's answer to `update` printed, and what it kept frozen: the exit code. */
|
|
658
827
|
function afterUpdate(
|
|
659
828
|
t: SubmissionTarget,
|
|
@@ -950,6 +1119,30 @@ function assembledPaper(
|
|
|
950
1119
|
: readPaper(join(paperDir, MAIN), new TextDecoder().decode(bytes), deps);
|
|
951
1120
|
}
|
|
952
1121
|
|
|
1122
|
+
/**
|
|
1123
|
+
* The paper's title (`titleOf`, falling back on the build's facts about `pdf`, none without one)
|
|
1124
|
+
* and its abstract (`sourceAbstract`): what `new` sends, and what `update` and `show` compare.
|
|
1125
|
+
*/
|
|
1126
|
+
function paperText(
|
|
1127
|
+
paperDir: string,
|
|
1128
|
+
pdf: Uint8Array | null,
|
|
1129
|
+
deps: SubmissionDeps,
|
|
1130
|
+
): {
|
|
1131
|
+
readonly title: Result<string, string>;
|
|
1132
|
+
readonly abstract: Result<string, string>;
|
|
1133
|
+
} {
|
|
1134
|
+
const paper = assembledPaper(paperDir, deps);
|
|
1135
|
+
const facts = pdf === null ? null : factsOfSent(paperDir, pdf, deps);
|
|
1136
|
+
const title = titleOf(
|
|
1137
|
+
paper === null
|
|
1138
|
+
? null
|
|
1139
|
+
: { text: paper.text, where: (o: number) => placeIn(paper, o) },
|
|
1140
|
+
deps.latex,
|
|
1141
|
+
facts?.text.metadata ?? null,
|
|
1142
|
+
);
|
|
1143
|
+
return { title, abstract: sourceAbstract(paper, deps) };
|
|
1144
|
+
}
|
|
1145
|
+
|
|
953
1146
|
/** The title and the abstract: the paper's `\title`, and `--abstract`'s file or the source's abstract. */
|
|
954
1147
|
function titleAndAbstract(
|
|
955
1148
|
a: SubmissionArgs & { readonly paperDir: string },
|
|
@@ -958,20 +1151,11 @@ function titleAndAbstract(
|
|
|
958
1151
|
): Result<{ readonly title: string; readonly abstract: string }, string> {
|
|
959
1152
|
const own = abstractOf(a, deps);
|
|
960
1153
|
if (!own.ok) return own;
|
|
961
|
-
const
|
|
962
|
-
const
|
|
963
|
-
const title = titleOf(
|
|
964
|
-
paper === null
|
|
965
|
-
? null
|
|
966
|
-
: { text: paper.text, where: (o: number) => placeIn(paper, o) },
|
|
967
|
-
deps.latex,
|
|
968
|
-
metadata,
|
|
969
|
-
);
|
|
1154
|
+
const text = paperText(a.paperDir, pdf, deps);
|
|
1155
|
+
const title = text.title;
|
|
970
1156
|
if (!title.ok) return title;
|
|
971
1157
|
const abstract =
|
|
972
|
-
own.value === null
|
|
973
|
-
? sourceAbstract(paper, deps)
|
|
974
|
-
: ok(own.value.replace(/\s+/g, " "));
|
|
1158
|
+
own.value === null ? text.abstract : ok(own.value.replace(/\s+/g, " "));
|
|
975
1159
|
return abstract.ok
|
|
976
1160
|
? ok({ title: title.value, abstract: abstract.value })
|
|
977
1161
|
: abstract;
|