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.
Files changed (117) hide show
  1. package/CLAUDE.md +3 -3
  2. package/CONTRIBUTING.md +5 -2
  3. package/README.md +6 -6
  4. package/dist/adapters/clack/index.d.ts +3 -0
  5. package/dist/adapters/clack/index.d.ts.map +1 -0
  6. package/dist/adapters/clack/index.js +3 -0
  7. package/dist/adapters/clack/index.js.map +1 -0
  8. package/dist/adapters/clack/prompts.io.d.ts +8 -0
  9. package/dist/adapters/clack/prompts.io.d.ts.map +1 -0
  10. package/dist/adapters/clack/prompts.io.js +20 -0
  11. package/dist/adapters/clack/prompts.io.js.map +1 -0
  12. package/dist/adapters/hotcrp/portal.io.d.ts.map +1 -1
  13. package/dist/adapters/hotcrp/portal.io.js +1 -0
  14. package/dist/adapters/hotcrp/portal.io.js.map +1 -1
  15. package/dist/adapters/hotcrp/response.d.ts.map +1 -1
  16. package/dist/adapters/hotcrp/response.js +15 -0
  17. package/dist/adapters/hotcrp/response.js.map +1 -1
  18. package/dist/adapters/package-manager/index.d.ts +4 -0
  19. package/dist/adapters/package-manager/index.d.ts.map +1 -0
  20. package/dist/adapters/package-manager/index.js +4 -0
  21. package/dist/adapters/package-manager/index.js.map +1 -0
  22. package/dist/adapters/package-manager/install.io.d.ts +3 -0
  23. package/dist/adapters/package-manager/install.io.d.ts.map +1 -0
  24. package/dist/adapters/package-manager/install.io.js +23 -0
  25. package/dist/adapters/package-manager/install.io.js.map +1 -0
  26. package/dist/adapters/package-manager/manager.d.ts +13 -0
  27. package/dist/adapters/package-manager/manager.d.ts.map +1 -0
  28. package/dist/adapters/package-manager/manager.js +22 -0
  29. package/dist/adapters/package-manager/manager.js.map +1 -0
  30. package/dist/adapters/study-registry/index.d.ts +2 -2
  31. package/dist/cli.d.ts +4 -1
  32. package/dist/cli.d.ts.map +1 -1
  33. package/dist/cli.js +47 -9
  34. package/dist/cli.js.map +1 -1
  35. package/dist/domain/submission.d.ts +4 -0
  36. package/dist/domain/submission.d.ts.map +1 -1
  37. package/dist/domain/submission.js.map +1 -1
  38. package/dist/init.d.ts +38 -15
  39. package/dist/init.d.ts.map +1 -1
  40. package/dist/init.js +99 -39
  41. package/dist/init.js.map +1 -1
  42. package/dist/ports/project-install.d.ts +19 -0
  43. package/dist/ports/project-install.d.ts.map +1 -0
  44. package/dist/ports/project-install.js +2 -0
  45. package/dist/ports/project-install.js.map +1 -0
  46. package/dist/ports/prompts.d.ts +31 -0
  47. package/dist/ports/prompts.d.ts.map +1 -0
  48. package/dist/ports/prompts.js +2 -0
  49. package/dist/ports/prompts.js.map +1 -0
  50. package/dist/self-install.d.ts +65 -0
  51. package/dist/self-install.d.ts.map +1 -0
  52. package/dist/self-install.js +145 -0
  53. package/dist/self-install.js.map +1 -0
  54. package/dist/skill-chunks/chunk-65X5HVIJ.js +26462 -0
  55. package/dist/skill-chunks/chunk-6NU6CXUS.js +258 -0
  56. package/dist/skill-chunks/chunk-GRSXIWYF.js +352 -0
  57. package/dist/skill-chunks/chunk-IREAROCV.js +84 -0
  58. package/dist/skill-chunks/chunk-KWK6RT4T.js +24267 -0
  59. package/dist/skill-chunks/chunk-NPQVDEE4.js +19681 -0
  60. package/dist/skill-chunks/chunk-PJ4KNV4J.js +45 -0
  61. package/dist/skill-chunks/dist-UPCJMLBM.js +385 -0
  62. package/dist/skill-chunks/pdfjs-LUMEFOH2.js +39518 -0
  63. package/dist/submission.d.ts +19 -2
  64. package/dist/submission.d.ts.map +1 -1
  65. package/dist/submission.js +121 -17
  66. package/dist/submission.js.map +1 -1
  67. package/docs/e2e.md +10 -0
  68. package/docs/install.md +27 -16
  69. package/docs/prior-art/README.md +2 -0
  70. package/docs/prior-art/one-command-install.md +33 -0
  71. package/docs/prior-art/prompt-libraries.md +32 -0
  72. package/docs/submission.md +19 -4
  73. package/eslint.config.mjs +1 -0
  74. package/lib/skill-checks.mjs +17 -9
  75. package/lib/skill-checks.test.mjs +28 -15
  76. package/lib/skill-corpus.mjs +5 -2
  77. package/package.json +5 -3
  78. package/scripts/bundle-skills.test.ts +226 -0
  79. package/scripts/bundle-skills.ts +304 -0
  80. package/skills/argument-arc/SKILL.md +2 -2
  81. package/skills/argument-arc/SKILL.md.spec.ts +1 -1
  82. package/skills/argument-arc/scripts/headings.js +57 -13
  83. package/skills/build-label-page/scripts/label-page.js +2005 -93
  84. package/skills/cold-read-diff/scripts/cold-read.js +221 -14
  85. package/skills/label-agent-runs/scripts/labels.js +272 -348
  86. package/skills/paper-pipeline/scripts/extract-ref-facts.js +304 -0
  87. package/skills/pc-panel-review/scripts/prior-reviews.js +7244 -12
  88. package/skills/run-agent-grid/scripts/grid-guard.js +562 -627
  89. package/skills/verify-citations/SKILL.md +9 -9
  90. package/skills/verify-citations/SKILL.md.spec.ts +8 -8
  91. package/skills/verify-citations/scripts/bib-authors.js +228 -0
  92. package/skills/verify-citations/scripts/verify-cites.js +816 -0
  93. package/src/adapters/clack/index.ts +2 -0
  94. package/src/adapters/clack/prompts.io.ts +35 -0
  95. package/src/adapters/clack/prompts.test.ts +58 -0
  96. package/src/adapters/hotcrp/portal.io.ts +1 -0
  97. package/src/adapters/hotcrp/portal.test.ts +43 -2
  98. package/src/adapters/hotcrp/response.ts +21 -0
  99. package/src/adapters/package-manager/index.test.ts +67 -0
  100. package/src/adapters/package-manager/index.ts +3 -0
  101. package/src/adapters/package-manager/install.io.ts +27 -0
  102. package/src/adapters/package-manager/manager.ts +33 -0
  103. package/src/cli.harness.mjs +41 -26
  104. package/src/cli.test.ts +93 -2
  105. package/src/cli.ts +80 -7
  106. package/src/domain/submission.ts +4 -0
  107. package/src/init.test.ts +138 -27
  108. package/src/init.ts +128 -72
  109. package/src/ports/project-install.ts +18 -0
  110. package/src/ports/prompts.ts +27 -0
  111. package/src/self-install.test.ts +267 -0
  112. package/src/self-install.ts +224 -0
  113. package/src/submission-fields-run.test.ts +1 -0
  114. package/src/submission-prior-reviews.test.ts +9 -1
  115. package/src/submission-show.test.ts +81 -0
  116. package/src/submission-update.test.ts +164 -6
  117. package/src/submission.ts +208 -24
@@ -0,0 +1,267 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { memoryFiles } from "./adapters/memory/index.ts";
3
+ import { absolutePath } from "./domain/paths.ts";
4
+ import type { ProjectInstall } from "./ports/project-install.ts";
5
+ import {
6
+ installSelf,
7
+ manifestName,
8
+ reportSelfInstall,
9
+ selfInstallStep,
10
+ versionOf,
11
+ type Copy,
12
+ type SelfInstallDeps,
13
+ } from "./self-install.ts";
14
+ import { scriptedPrompts, type Reply } from "../test/support.ts";
15
+
16
+ const ROOT = absolutePath("/work/My Papers");
17
+ const MANIFEST = "/work/My Papers/package.json";
18
+ const RUNNING: Copy = { dir: "/npx/paperlint", version: "2.0.0" };
19
+
20
+ /** An installer that records what it ran, and exits as told. */
21
+ const recording = (ok = true) => {
22
+ const ran: (readonly string[])[] = [];
23
+ const install: ProjectInstall = {
24
+ command: (_root, spec) => [
25
+ "npm",
26
+ "install",
27
+ "--save-dev",
28
+ "--save-exact",
29
+ spec,
30
+ ],
31
+ run: (_root, argv) => (
32
+ ran.push(argv),
33
+ ok ? { ok: true } : { ok: false, reason: "exited 1" }
34
+ ),
35
+ };
36
+ return { ran, install };
37
+ };
38
+
39
+ const setup = ({
40
+ installed = null,
41
+ manifest = '{"name":"x"}\n',
42
+ ok = true,
43
+ }: {
44
+ installed?: Copy | null;
45
+ manifest?: string | null;
46
+ ok?: boolean;
47
+ } = {}) => {
48
+ const files = memoryFiles(manifest === null ? {} : { [MANIFEST]: manifest });
49
+ const { ran, install } = recording(ok);
50
+ const deps: SelfInstallDeps = {
51
+ running: RUNNING,
52
+ installed: () => installed,
53
+ files,
54
+ install,
55
+ spec: "paperlint@2.0.0",
56
+ };
57
+ const said: string[] = [];
58
+ const go = (opts: { interactive: boolean; reply?: Reply }) => {
59
+ const prompts = scriptedPrompts(() => opts.reply);
60
+ return installSelf(ROOT, deps, {
61
+ prompts,
62
+ interactive: opts.interactive,
63
+ log: (l) => said.push(l),
64
+ }).then((r) => ({ r, asked: prompts.asked }));
65
+ };
66
+ /** The whole step as the CLI runs it: its exit code (null: go on to init) and every line printed. */
67
+ const step = async (opts: { interactive: boolean; reply?: Reply }) => {
68
+ const out: string[] = [];
69
+ const code = await selfInstallStep(
70
+ ROOT,
71
+ deps,
72
+ {
73
+ prompts: scriptedPrompts(() => opts.reply),
74
+ interactive: opts.interactive,
75
+ log: (l) => out.push(l),
76
+ },
77
+ { code: 130, line: "CANCELLED" },
78
+ );
79
+ return { code, out };
80
+ };
81
+ return { files, ran, said, go, step };
82
+ };
83
+
84
+ const COMMAND = "npm install --save-dev --save-exact paperlint@2.0.0";
85
+
86
+ describe("installSelf — paperlint added to the project it runs in", () => {
87
+ it("the project's own copy: nothing asked, nothing run", async () => {
88
+ const s = setup({ installed: RUNNING });
89
+ const { r, asked } = await s.go({ interactive: true });
90
+ expect([r, asked, s.ran]).toEqual([{ kind: "present" }, [], []]);
91
+ expect(reportSelfInstall(r)).toEqual([]);
92
+ });
93
+
94
+ it("another copy at the same version counts as present", async () => {
95
+ const s = setup({ installed: { dir: "/elsewhere", version: "2.0.0" } });
96
+ expect((await s.go({ interactive: false })).r).toEqual({ kind: "present" });
97
+ });
98
+
99
+ it("🔴 another version installed: said, kept, never up- or downgraded", async () => {
100
+ const s = setup({ installed: { dir: "/proj/nm", version: "1.4.0" } });
101
+ const { r } = await s.go({ interactive: true, reply: true });
102
+ expect([r, s.ran]).toEqual([
103
+ {
104
+ kind: "other-version",
105
+ installed: "1.4.0",
106
+ running: "2.0.0",
107
+ command: COMMAND,
108
+ },
109
+ [],
110
+ ]);
111
+ expect(reportSelfInstall(r)).toEqual([
112
+ " ⚠ paperlint 1.4.0 is installed in this project, and this command is 2.0.0: kept 1.4.0, nothing up- or downgraded",
113
+ ` to move the project to 2.0.0: ${COMMAND}`,
114
+ ]);
115
+ });
116
+
117
+ it("no terminal: added without asking, the command printed before it runs", async () => {
118
+ const s = setup();
119
+ const { r, asked } = await s.go({ interactive: false });
120
+ expect([r, asked, s.said, s.ran.map((a) => a.join(" "))]).toEqual([
121
+ { kind: "added", command: COMMAND, manifest: null },
122
+ [],
123
+ [` → ${COMMAND}`],
124
+ [COMMAND],
125
+ ]);
126
+ expect(reportSelfInstall(r)).toEqual([
127
+ " ✓ added paperlint to devDependencies",
128
+ ]);
129
+ });
130
+
131
+ it("no package.json: a minimal one is written first, and said", async () => {
132
+ const s = setup({ manifest: null });
133
+ const { r } = await s.go({ interactive: false });
134
+ expect(new TextDecoder().decode(s.files.map.get(MANIFEST))).toBe(
135
+ '{\n "name": "my-papers",\n "private": true\n}\n',
136
+ );
137
+ expect(reportSelfInstall(r)).toEqual([
138
+ ' ✓ wrote package.json ({ "name": "my-papers", "private": true }) — there was none',
139
+ " ✓ added paperlint to devDependencies",
140
+ ]);
141
+ });
142
+ });
143
+
144
+ describe("installSelf — a human at a terminal, and failures", () => {
145
+ it("a human: asked with Yes preselected; Enter adds it", async () => {
146
+ const s = setup();
147
+ const { r, asked } = await s.go({ interactive: true });
148
+ expect([r.kind, asked]).toEqual([
149
+ "added",
150
+ ["Add paperlint 2.0.0 to this project's devDependencies?"],
151
+ ]);
152
+ });
153
+
154
+ it("a human says No: nothing written or run, and the command to run by hand", async () => {
155
+ const s = setup({ manifest: null });
156
+ const { r } = await s.go({ interactive: true, reply: false });
157
+ expect([r, s.ran, s.files.map.size]).toEqual([
158
+ { kind: "declined", command: COMMAND },
159
+ [],
160
+ 0,
161
+ ]);
162
+ expect(reportSelfInstall(r)).toEqual([
163
+ ` · not added — run it yourself, then \`npx paperlint init\` again: ${COMMAND}`,
164
+ ]);
165
+ });
166
+
167
+ it("Ctrl+C: cancelled, nothing run", async () => {
168
+ const s = setup();
169
+ const { r } = await s.go({ interactive: true, reply: "cancel" });
170
+ expect([r, s.ran, reportSelfInstall(r)]).toEqual([
171
+ { kind: "cancelled" },
172
+ [],
173
+ [],
174
+ ]);
175
+ });
176
+
177
+ it("a question that failed takes its default, Yes", async () => {
178
+ const s = setup();
179
+ const { r } = await s.go({
180
+ interactive: true,
181
+ reply: new Error("stream ended"),
182
+ });
183
+ expect(r.kind).toBe("added");
184
+ });
185
+
186
+ it("the package manager failed: said, with what to run by hand", async () => {
187
+ const s = setup({ ok: false, manifest: null });
188
+ const { r } = await s.go({ interactive: false });
189
+ expect(reportSelfInstall(r)).toEqual([
190
+ ' ✓ wrote package.json ({ "name": "my-papers", "private": true }) — there was none',
191
+ ` ✗ ${COMMAND} failed (exited 1) — nothing else was done. Run it yourself, then \`npx paperlint init\` again`,
192
+ ]);
193
+ });
194
+ });
195
+
196
+ describe("selfInstallStep — step 0 of init, as the CLI runs it", () => {
197
+ it("present: silent, and init goes on", async () => {
198
+ expect(
199
+ await setup({ installed: RUNNING }).step({ interactive: false }),
200
+ ).toEqual({
201
+ code: null,
202
+ out: [],
203
+ });
204
+ });
205
+
206
+ it("added without a terminal: the header with the command, then what happened; init goes on", async () => {
207
+ expect(await setup().step({ interactive: false })).toEqual({
208
+ code: null,
209
+ out: [
210
+ `\npaperlint in this project\n → ${COMMAND}`,
211
+ " ✓ added paperlint to devDependencies",
212
+ ],
213
+ });
214
+ });
215
+
216
+ it("a human says No: the header and the command to run by hand; init stops, exit 0", async () => {
217
+ expect(await setup().step({ interactive: true, reply: false })).toEqual({
218
+ code: 0,
219
+ out: [
220
+ `\npaperlint in this project\n · not added — run it yourself, then \`npx paperlint init\` again: ${COMMAND}`,
221
+ ],
222
+ });
223
+ });
224
+
225
+ it("the install failed: init stops, exit 2", async () => {
226
+ expect((await setup({ ok: false }).step({ interactive: false })).code).toBe(
227
+ 2,
228
+ );
229
+ });
230
+
231
+ it("Ctrl+C: the cancel line and its code", async () => {
232
+ expect(await setup().step({ interactive: true, reply: "cancel" })).toEqual({
233
+ code: 130,
234
+ out: ["CANCELLED"],
235
+ });
236
+ });
237
+
238
+ it("another version: said under the header, and init goes on with it", async () => {
239
+ const r = await setup({ installed: { dir: "/p", version: "1.4.0" } }).step({
240
+ interactive: false,
241
+ });
242
+ expect([
243
+ r.code,
244
+ r.out.length,
245
+ r.out[0]?.startsWith("\npaperlint in this project\n ⚠ paperlint 1.4.0"),
246
+ ]).toEqual([null, 2, true]);
247
+ });
248
+ });
249
+
250
+ describe("manifestName and versionOf", () => {
251
+ it("a folder's name, as npm accepts one; nothing usable is `papers`", () => {
252
+ expect([
253
+ manifestName("/a/My Papers!"),
254
+ manifestName("/a/.hidden"),
255
+ manifestName("/a/..."),
256
+ ]).toEqual(["my-papers-", "hidden", "papers"]);
257
+ });
258
+
259
+ it("the version a package.json names, or null", () => {
260
+ const enc = (s: string) => new TextEncoder().encode(s);
261
+ expect([
262
+ versionOf(null),
263
+ versionOf(enc('{"name":"x"}')),
264
+ versionOf(enc('{"version":"1.2.3"}')),
265
+ ]).toEqual([null, null, "1.2.3"]);
266
+ });
267
+ });
@@ -0,0 +1,224 @@
1
+ /**
2
+ * `npx paperlint init` adds paperlint to the project it runs in, so the install is one command
3
+ * (docs/prior-art/one-command-install.md, after `npm init @eslint/config`).
4
+ *
5
+ * ── THE DECISIONS ─────────────────────────────────────────────────────────────
6
+ * already installed the project's copy resolves by name: nothing is added. At another version
7
+ * than the running one it is SAID and kept — never up- or downgraded silently.
8
+ * what is added `paperlint@<the running version>`, saved exact, so the command that ran and
9
+ * the package it added cannot drift.
10
+ * which manager the project's lockfile decides (`src/adapters/package-manager/`).
11
+ * no package.json a minimal one is written first (private, the folder's name), and said.
12
+ * asking a human is asked, Yes preselected; No stops init with the command to run by
13
+ * hand. Without a human it is added unasked, the command printed: that is what
14
+ * running init asked for.
15
+ */
16
+ import { basename } from "node:path";
17
+ import { z } from "zod";
18
+ import { joinPath, type AbsolutePath } from "./domain/paths.ts";
19
+ import type { Files } from "./ports/files.ts";
20
+ import type { ProjectInstall } from "./ports/project-install.ts";
21
+ import type { Answer, Prompts } from "./ports/prompts.ts";
22
+
23
+ /** One copy of paperlint: where it is, and its version. */
24
+ export interface Copy {
25
+ readonly dir: string;
26
+ readonly version: string;
27
+ }
28
+
29
+ export interface SelfInstallDeps {
30
+ /** The copy this command runs from. */
31
+ readonly running: Copy;
32
+ /** The project's own copy, as it resolves by name from the project, or null. */
33
+ readonly installed: (root: AbsolutePath) => Copy | null;
34
+ readonly files: Files;
35
+ readonly install: ProjectInstall;
36
+ /** What is added: `paperlint@<running version>` unless the CLI was told otherwise. */
37
+ readonly spec: string;
38
+ }
39
+
40
+ export type SelfInstall =
41
+ | { readonly kind: "present" }
42
+ | {
43
+ readonly kind: "other-version";
44
+ readonly installed: string;
45
+ readonly running: string;
46
+ readonly command: string;
47
+ }
48
+ | {
49
+ readonly kind: "added";
50
+ readonly command: string;
51
+ readonly manifest: string | null;
52
+ }
53
+ | { readonly kind: "declined"; readonly command: string }
54
+ | {
55
+ readonly kind: "failed";
56
+ readonly command: string;
57
+ readonly reason: string;
58
+ readonly manifest: string | null;
59
+ }
60
+ | { readonly kind: "cancelled" };
61
+
62
+ /** The name a new package.json gets: the folder's, as npm accepts a name. */
63
+ export const manifestName = (root: string): string =>
64
+ basename(root)
65
+ .toLowerCase()
66
+ .replace(/[^a-z0-9._-]+/g, "-")
67
+ .replace(/^[._-]+/, "") || "papers";
68
+
69
+ const encode = (text: string): Uint8Array => new TextEncoder().encode(text);
70
+
71
+ /** Writes a minimal package.json when there is none; the name it was given, or null when one was there. */
72
+ function ensureManifest(root: AbsolutePath, files: Files): string | null {
73
+ const path = joinPath(root, "package.json");
74
+ if (files.readBytes(path) !== null) return null;
75
+ const name = manifestName(root);
76
+ files.writeAtomic(
77
+ path,
78
+ encode(`${JSON.stringify({ name, private: true }, null, 2)}\n`),
79
+ );
80
+ return name;
81
+ }
82
+
83
+ /** Asks whether to add it; a prompt that fails is the default, Yes. */
84
+ async function confirmed(
85
+ prompts: Prompts,
86
+ version: string,
87
+ ): Promise<Answer<boolean>> {
88
+ try {
89
+ return await prompts.confirm({
90
+ message: `Add paperlint ${version} to this project's devDependencies?`,
91
+ initial: true,
92
+ });
93
+ } catch {
94
+ return { kind: "answer", value: true };
95
+ }
96
+ }
97
+
98
+ /** How init asks, and where it prints. */
99
+ export interface Asking {
100
+ readonly prompts?: Prompts | undefined;
101
+ readonly interactive: boolean;
102
+ readonly log: (line: string) => void;
103
+ }
104
+
105
+ /** The project's copy against the running one; null when the project has none. */
106
+ const alreadyThere = (
107
+ here: Copy | null,
108
+ running: Copy,
109
+ command: string,
110
+ ): SelfInstall | null => {
111
+ if (here === null) return null;
112
+ return here.dir === running.dir || here.version === running.version
113
+ ? { kind: "present" }
114
+ : {
115
+ kind: "other-version",
116
+ installed: here.version,
117
+ running: running.version,
118
+ command,
119
+ };
120
+ };
121
+
122
+ /** Whether a human said No, cancelled, or (or nobody was asked) it goes ahead: null. */
123
+ async function refused(
124
+ deps: SelfInstallDeps,
125
+ { prompts, interactive }: Asking,
126
+ command: string,
127
+ ): Promise<SelfInstall | null> {
128
+ if (!interactive || !prompts) return null;
129
+ const answer = await confirmed(prompts, deps.running.version);
130
+ if (answer.kind === "cancel") return { kind: "cancelled" };
131
+ return answer.value ? null : { kind: "declined", command };
132
+ }
133
+
134
+ export async function installSelf(
135
+ root: AbsolutePath,
136
+ deps: SelfInstallDeps,
137
+ asking: Asking,
138
+ ): Promise<SelfInstall> {
139
+ const command = deps.install.command(root, deps.spec);
140
+ const shown = command.join(" ");
141
+ const stop =
142
+ alreadyThere(deps.installed(root), deps.running, shown) ??
143
+ (await refused(deps, asking, shown));
144
+ if (stop !== null) return stop;
145
+ const manifest = ensureManifest(root, deps.files);
146
+ asking.log(` → ${shown}`);
147
+ const ran = deps.install.run(root, command);
148
+ return ran.ok
149
+ ? { kind: "added", command: shown, manifest }
150
+ : { kind: "failed", command: shown, reason: ran.reason, manifest };
151
+ }
152
+
153
+ const SELF_HEADER = `paperlint in this project`;
154
+
155
+ /**
156
+ * Step 0 of `paperlint init`, run by the CLI before init itself: paperlint added to the project.
157
+ * Null to go on to init; otherwise the exit code to stop with (No: 0, a failed install: 2, Ctrl+C:
158
+ * `cancelledCode`). The header is printed with the first line, so a project that has paperlint
159
+ * already sees nothing.
160
+ */
161
+ export async function selfInstallStep(
162
+ root: AbsolutePath,
163
+ deps: SelfInstallDeps,
164
+ asking: Asking,
165
+ cancelled: { readonly code: number; readonly line: string },
166
+ ): Promise<number | null> {
167
+ const say = (line: string): void => {
168
+ asking.log([``, SELF_HEADER, line].join("\n"));
169
+ };
170
+ const r = await installSelf(root, deps, { ...asking, log: say });
171
+ if (r.kind === "cancelled") {
172
+ asking.log(cancelled.line);
173
+ return cancelled.code;
174
+ }
175
+ const [first, ...rest] = reportSelfInstall(r);
176
+ const announced = r.kind === "added" || r.kind === "failed";
177
+ if (first !== undefined)
178
+ [announced ? first : [``, SELF_HEADER, first].join("\n"), ...rest].forEach(
179
+ (line) => {
180
+ asking.log(line);
181
+ },
182
+ );
183
+ if (r.kind === "declined") return 0;
184
+ return r.kind === "failed" ? 2 : null;
185
+ }
186
+
187
+ const manifestLine = (name: string | null): readonly string[] =>
188
+ name === null
189
+ ? []
190
+ : [
191
+ ` ✓ wrote package.json ({ "name": "${name}", "private": true }) — there was none`,
192
+ ];
193
+
194
+ /** The section's lines, written after the command ran; empty when paperlint was already there. */
195
+ export function reportSelfInstall(r: SelfInstall): readonly string[] {
196
+ if (r.kind === "present" || r.kind === "cancelled") return [];
197
+ if (r.kind === "other-version")
198
+ return [
199
+ ` ⚠ paperlint ${r.installed} is installed in this project, and this command is ${r.running}: kept ${r.installed}, nothing up- or downgraded`,
200
+ ` to move the project to ${r.running}: ${r.command}`,
201
+ ];
202
+ if (r.kind === "declined")
203
+ return [
204
+ ` · not added — run it yourself, then \`npx paperlint init\` again: ${r.command}`,
205
+ ];
206
+ if (r.kind === "failed")
207
+ return [
208
+ ...manifestLine(r.manifest),
209
+ ` ✗ ${r.command} failed (${r.reason}) — nothing else was done. Run it yourself, then \`npx paperlint init\` again`,
210
+ ];
211
+ return [
212
+ ...manifestLine(r.manifest),
213
+ ` ✓ added paperlint to devDependencies`,
214
+ ];
215
+ }
216
+
217
+ /** The version a package.json names, or null. */
218
+ export const versionOf = (bytes: Uint8Array | null): string | null => {
219
+ if (bytes === null) return null;
220
+ const parsed = z
221
+ .object({ version: z.string() })
222
+ .safeParse(JSON.parse(new TextDecoder().decode(bytes)));
223
+ return parsed.success ? parsed.data.version : null;
224
+ };
@@ -42,6 +42,7 @@ test("update: the paper's fields are checked and sent with the change, and print
42
42
  7,
43
43
  {
44
44
  pdf: { name: "paper.pdf", bytes: PDF },
45
+ title: null,
45
46
  abstract: null,
46
47
  submit: false,
47
48
  fields: FIELDS,
@@ -91,7 +91,15 @@ test("the dry run prints the same lines and goes on: the author reads them befor
91
91
  { sub: "update" },
92
92
  { files: paper([REVIEWED, SENT], UNANSWERED) },
93
93
  );
94
- expect([r.code, r.errs, r.seen[0]?.calls.length]).toStrictEqual([0, [], 1]);
94
+ // The paper has a \title, so `update` reads the portal's before it sends (#619).
95
+ expect([r.code, r.errs, r.seen[0]?.calls]).toStrictEqual([
96
+ 0,
97
+ [],
98
+ [
99
+ ["show", 7],
100
+ ["update", 7, expect.anything(), { save: false }],
101
+ ],
102
+ ]);
95
103
  expect(r.out.slice(2, 4)).toStrictEqual([HEADING, UNANSWERED_LINE]);
96
104
  });
97
105
 
@@ -20,6 +20,10 @@ import {
20
20
  fakePortal,
21
21
  run,
22
22
  STEPS,
23
+ files,
24
+ DEFAULT_TEX,
25
+ AUTHORS,
26
+ WANT,
23
27
  } from "../test/submission-fixtures.ts";
24
28
  import { frozenText } from "../test/frozen-presets.ts";
25
29
 
@@ -217,3 +221,80 @@ test("show, in the flat form: the deadlines in force are the preset's readings a
217
221
  });
218
222
 
219
223
  // ── new ───────────────────────────────────────────────────────────────────────────────
224
+
225
+ /** The made-up paper with its source and its authors, against `view` on the portal. */
226
+ const against = (view: Partial<SubmissionView>, paper: object = {}) =>
227
+ run(
228
+ {},
229
+ {
230
+ files: files({
231
+ paper: {
232
+ extends: "../../venue.jsonc",
233
+ submission: { id: 7 },
234
+ authors: AUTHORS,
235
+ ...paper,
236
+ },
237
+ extra: { [`${PAPER}/paper.tex`]: DEFAULT_TEX },
238
+ }),
239
+ portal: fakePortal({ show: ok({ ...VIEW, ...view }) }),
240
+ },
241
+ );
242
+
243
+ test("🔴 show: a portal title, abstract or authors that are not the paper's are flagged, with what changes each", async () => {
244
+ const r = await against({
245
+ authors: [
246
+ {
247
+ name: "A. Author",
248
+ email: "author@example.org",
249
+ affiliation: "Example University",
250
+ },
251
+ ],
252
+ });
253
+ expect(r.code).toBe(0);
254
+ expect(r.out.slice(2, 9)).toStrictEqual([
255
+ "title A Fake Title",
256
+ "paper title Agents That Lie — NOT the portal's; `paperlint submission update` sends it",
257
+ "paper type Regular",
258
+ "topics A; B",
259
+ "abstract 4 words",
260
+ "paper abstract 17 words — NOT the portal's; `paperlint submission update` sends it",
261
+ "paper authors Ada Lovelace <ada@example.org>, Analytical; Bob Bobson <bob@example.org> — NOT the portal's (A. Author <author@example.org>, Example University); `paperlint submission update` does not change the authors: change them on the site",
262
+ ]);
263
+ });
264
+
265
+ test("show: what matches the paper adds no line — spacing, the case of an email, an affiliation left out on both", async () => {
266
+ const r = await against({
267
+ title: "Agents That Lie",
268
+ abstract: ` ${WANT.abstract}`,
269
+ authors: [
270
+ {
271
+ name: "Ada Lovelace",
272
+ email: "ADA@example.org",
273
+ affiliation: "Analytical",
274
+ },
275
+ { name: "Bob Bobson", email: "bob@example.org", affiliation: null },
276
+ ],
277
+ });
278
+ expect(r.out.slice(2, 7)).toStrictEqual([
279
+ "title Agents That Lie",
280
+ "paper type Regular",
281
+ "topics A; B",
282
+ "abstract 17 words",
283
+ `portal PDF sha2-${HEX}, ${String(PDF.length)} bytes, uploaded 1970-01-01T00:00:00.000Z`,
284
+ ]);
285
+ });
286
+
287
+ test("show: authors compared only when both sides name them, and an author missing on one side is a difference", async () => {
288
+ const same = { title: "Agents That Lie", abstract: WANT.abstract };
289
+ const quiet = [
290
+ await against({ ...same, authors: null }),
291
+ await against({ ...same, authors: WANT.authors }, { authors: undefined }),
292
+ ];
293
+ expect(
294
+ quiet.map((r) => r.out.some((l) => l.startsWith("paper authors"))),
295
+ ).toStrictEqual([false, false]);
296
+ const fewer = await against({ ...same, authors: WANT.authors.slice(0, 1) });
297
+ expect(fewer.out[6]).toBe(
298
+ "paper authors Ada Lovelace <ada@example.org>, Analytical; Bob Bobson <bob@example.org> — NOT the portal's (Ada Lovelace <ada@example.org>, Analytical); `paperlint submission update` does not change the authors: change them on the site",
299
+ );
300
+ });