paperlint 18.4.1 → 18.6.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 +6 -2
- 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/latex/abstract.d.ts +11 -0
- package/dist/adapters/latex/abstract.d.ts.map +1 -1
- package/dist/adapters/latex/abstract.js +1 -1
- package/dist/adapters/latex/abstract.js.map +1 -1
- package/dist/adapters/latex/index.d.ts.map +1 -1
- package/dist/adapters/latex/index.js +3 -0
- package/dist/adapters/latex/index.js.map +1 -1
- package/dist/adapters/latex/macros.d.ts +6 -0
- package/dist/adapters/latex/macros.d.ts.map +1 -0
- package/dist/adapters/latex/macros.js +27 -0
- package/dist/adapters/latex/macros.js.map +1 -0
- package/dist/adapters/osf/host.io.d.ts +12 -0
- package/dist/adapters/osf/host.io.d.ts.map +1 -0
- package/dist/adapters/osf/host.io.js +119 -0
- package/dist/adapters/osf/host.io.js.map +1 -0
- package/dist/adapters/osf/index.d.ts +10 -0
- package/dist/adapters/osf/index.d.ts.map +1 -0
- package/dist/adapters/osf/index.js +10 -0
- package/dist/adapters/osf/index.js.map +1 -0
- package/dist/adapters/osf/response.d.ts +11 -0
- package/dist/adapters/osf/response.d.ts.map +1 -0
- package/dist/adapters/osf/response.js +87 -0
- package/dist/adapters/osf/response.js.map +1 -0
- package/dist/artifact-upload-rule.d.ts +66 -0
- package/dist/artifact-upload-rule.d.ts.map +1 -0
- package/dist/artifact-upload-rule.js +151 -0
- package/dist/artifact-upload-rule.js.map +1 -0
- package/dist/artifact.d.ts +35 -0
- package/dist/artifact.d.ts.map +1 -0
- package/dist/artifact.js +251 -0
- package/dist/artifact.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +99 -7
- package/dist/cli.js.map +1 -1
- package/dist/domain/artifact-upload.d.ts +44 -0
- package/dist/domain/artifact-upload.d.ts.map +1 -0
- package/dist/domain/artifact-upload.js +80 -0
- package/dist/domain/artifact-upload.js.map +1 -0
- 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/eslint-rules/CLAUDE.md.spec.d.ts.map +1 -1
- package/dist/eslint-rules/CLAUDE.md.spec.js +1 -0
- package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
- package/dist/ports/artifact-host.d.ts +54 -0
- package/dist/ports/artifact-host.d.ts.map +1 -0
- package/dist/ports/artifact-host.js +2 -0
- package/dist/ports/artifact-host.js.map +1 -0
- package/dist/ports/latex.d.ts +9 -0
- package/dist/ports/latex.d.ts.map +1 -1
- package/dist/submission-confirm-hook.d.ts +11 -1
- package/dist/submission-confirm-hook.d.ts.map +1 -1
- package/dist/submission-confirm-hook.js +83 -21
- package/dist/submission-confirm-hook.js.map +1 -1
- 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/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/artifact-upload.md +124 -0
- package/docs/optional-rules.md +1 -0
- package/docs/osf-artifact.md +4 -1
- package/docs/rules/artifact/upload-current.md +85 -0
- package/docs/rules.md +1 -0
- package/docs/submission.md +19 -4
- package/eslint-rules/CLAUDE.md +5 -1
- package/eslint-rules/CLAUDE.md.spec.ts +3 -0
- package/package.json +1 -1
- 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/latex/abstract.ts +3 -1
- package/src/adapters/latex/index.ts +3 -0
- package/src/adapters/latex/macros.test.ts +31 -0
- package/src/adapters/latex/macros.ts +43 -0
- package/src/adapters/osf/cassette/README.md +20 -0
- package/src/adapters/osf/cassette/get-file.json +108 -0
- package/src/adapters/osf/cassette/get-listing.json +111 -0
- package/src/adapters/osf/cassette/get-missing.json +1 -0
- package/src/adapters/osf/cassette/put-new.json +31 -0
- package/src/adapters/osf/host.io.ts +156 -0
- package/src/adapters/osf/host.test.ts +274 -0
- package/src/adapters/osf/index.ts +14 -0
- package/src/adapters/osf/response.ts +105 -0
- package/src/artifact-upload-rule.test.ts +213 -0
- package/src/artifact-upload-rule.ts +213 -0
- package/src/artifact.test.ts +504 -0
- package/src/artifact.ts +402 -0
- package/src/cli.test.ts +149 -1
- package/src/cli.ts +121 -8
- package/src/domain/artifact-upload.test.ts +80 -0
- package/src/domain/artifact-upload.ts +111 -0
- package/src/domain/submission.ts +4 -0
- package/src/ports/artifact-host.ts +65 -0
- package/src/ports/latex.ts +10 -0
- package/src/rule-cases.test.ts +44 -0
- package/src/submission-confirm-hook.test.ts +113 -1
- package/src/submission-confirm-hook.ts +120 -27
- 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
- package/src/types.ts +6 -0
|
@@ -9,7 +9,7 @@ import type { AbsolutePath } from "./domain/paths.ts";
|
|
|
9
9
|
import { sha256Hex } from "./domain/sha256.ts";
|
|
10
10
|
import type { Files } from "./ports/files.ts";
|
|
11
11
|
import { leafCommandsNormalized as shellLeaves } from "vigiles/hook";
|
|
12
|
-
import { submissionSend } from "./cli.ts";
|
|
12
|
+
import { submissionSend, uploadSend } from "./cli.ts";
|
|
13
13
|
import { presetsDir } from "./package-dirs.ts";
|
|
14
14
|
import {
|
|
15
15
|
submissionConfirm as confirmWith,
|
|
@@ -43,6 +43,7 @@ const submissionConfirm = (
|
|
|
43
43
|
portalHosts: () => HOSTS,
|
|
44
44
|
shellLeaves,
|
|
45
45
|
readSend: submissionSend,
|
|
46
|
+
readUpload: uploadSend,
|
|
46
47
|
...more,
|
|
47
48
|
});
|
|
48
49
|
|
|
@@ -830,3 +831,114 @@ test("the approved command start is compared as written; the host in any case",
|
|
|
830
831
|
decide(`Run ${command.replace("paper.pdf", "PAPER.PDF")} on hotcrp.com?`),
|
|
831
832
|
).toBe("deny");
|
|
832
833
|
});
|
|
834
|
+
|
|
835
|
+
// ── an artifact upload that saves is a send ──────────────────────────────────────────────
|
|
836
|
+
|
|
837
|
+
const ZIP = new TextEncoder().encode("zip bytes");
|
|
838
|
+
const ZIP_SHA = sha256Hex(ZIP).slice(0, 12);
|
|
839
|
+
const UPLOAD =
|
|
840
|
+
"npx paperlint artifact upload --to osf a.zip --node abcde papers/p --save";
|
|
841
|
+
const withZip = (lines: readonly string[], command = UPLOAD) =>
|
|
842
|
+
submissionConfirm(
|
|
843
|
+
payload(command),
|
|
844
|
+
memoryFiles({ [T]: `${lines.join("\n")}\n`, "/w/a.zip": ZIP }),
|
|
845
|
+
)?.hookSpecificOutput.permissionDecisionReason ?? null;
|
|
846
|
+
|
|
847
|
+
test("🔴 artifact upload --save, no yes: refused, naming the folder and the file's sha256 to ask about", () => {
|
|
848
|
+
// Guards: the whole refusal an agent reads.
|
|
849
|
+
expect(withZip([])).toBe(
|
|
850
|
+
[
|
|
851
|
+
"Not run: this uploads the paper's artifact to its host, and the person has not said yes to it since the last send.",
|
|
852
|
+
"paper folder: /w/papers/p",
|
|
853
|
+
`artifact: a.zip, sha256 ${ZIP_SHA}`,
|
|
854
|
+
"to: osf project abcde",
|
|
855
|
+
"Ask the person with AskUserQuestion first, then run this command again. In the question, give the paper folder (the full path), the artifact's file and sha256, and the project, as written above.",
|
|
856
|
+
'Options: "Yes, upload it" and "No". One yes lets one upload through.',
|
|
857
|
+
].join("\n"),
|
|
858
|
+
);
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
test("artifact upload --save runs after a yes naming its folder, sha256 and project, once; the dry run is never gated", () => {
|
|
862
|
+
const yes = question(
|
|
863
|
+
"q1",
|
|
864
|
+
`Upload a.zip (paper folder /w/papers/p, sha256 ${ZIP_SHA}) to osf project abcde?`,
|
|
865
|
+
"Yes, upload it",
|
|
866
|
+
);
|
|
867
|
+
// Guards: a yes lets it through.
|
|
868
|
+
expect(withZip(yes)).toBe(null);
|
|
869
|
+
// Guards: an earlier upload uses that yes up.
|
|
870
|
+
expect(withZip([...yes, ...bash("b1", UPLOAD)])).toMatch(
|
|
871
|
+
/^Not run: this uploads/u,
|
|
872
|
+
);
|
|
873
|
+
// Guards: without --save, and record/show, nothing is asked.
|
|
874
|
+
expect(
|
|
875
|
+
withZip([], "npx paperlint artifact upload --to osf a.zip papers/p"),
|
|
876
|
+
).toBe(null);
|
|
877
|
+
expect(
|
|
878
|
+
withZip(
|
|
879
|
+
[],
|
|
880
|
+
"npx paperlint artifact record a.zip --url https://x.org --save",
|
|
881
|
+
),
|
|
882
|
+
).toBe(null);
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
test("🔴 a yes to one project does not approve an upload to another", () => {
|
|
886
|
+
const yes = question(
|
|
887
|
+
"q1",
|
|
888
|
+
`Upload a.zip (paper folder /w/papers/p, sha256 ${ZIP_SHA}) to osf project abcde?`,
|
|
889
|
+
"Yes, upload it",
|
|
890
|
+
);
|
|
891
|
+
const elsewhere = UPLOAD.replace("abcde", "zzzzz");
|
|
892
|
+
// Guards: the same folder and file, another --node: the yes does not cover it.
|
|
893
|
+
expect(withZip(yes, elsewhere)).toMatch(/^Not run: this uploads/u);
|
|
894
|
+
// Guards: a longer id that starts with the approved one is another project too.
|
|
895
|
+
expect(withZip(yes, UPLOAD.replace("abcde", "abcdef"))).toMatch(
|
|
896
|
+
/^Not run: this uploads/u,
|
|
897
|
+
);
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
test("artifact upload --save with a flag before the subcommand is a send too: refused without a yes, and it uses a yes up", () => {
|
|
901
|
+
const before =
|
|
902
|
+
"npx paperlint artifact --to osf upload a.zip --node abcde papers/p --save";
|
|
903
|
+
// Guards: the CLI reads the subcommand wherever the flags put it, so the hook must too.
|
|
904
|
+
expect(withZip([], before)).toMatch(/^Not run: this uploads/u);
|
|
905
|
+
const yes = question(
|
|
906
|
+
"q1",
|
|
907
|
+
`Upload a.zip (paper folder /w/papers/p, sha256 ${ZIP_SHA}) to project abcde?`,
|
|
908
|
+
"Yes, upload it",
|
|
909
|
+
);
|
|
910
|
+
// Guards: it runs on a yes, and an earlier one of its kind used that yes.
|
|
911
|
+
expect(withZip(yes, before)).toBe(null);
|
|
912
|
+
expect(withZip([...yes, ...bash("b1", before)])).toMatch(
|
|
913
|
+
/^Not run: this uploads/u,
|
|
914
|
+
);
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
test("artifact upload --save of a file that is not there, or words that do not parse: refused, nothing to ask about", () => {
|
|
918
|
+
// Guards: a missing file has no sha256 to ask about.
|
|
919
|
+
expect(
|
|
920
|
+
withZip(
|
|
921
|
+
[],
|
|
922
|
+
"npx paperlint artifact upload --to osf gone.zip --node abcde --save",
|
|
923
|
+
),
|
|
924
|
+
).toBe(
|
|
925
|
+
[
|
|
926
|
+
"Not run: this uploads the paper's artifact to its host, and paperlint cannot find the file it uploads, so there is no sha256 to ask the person about.",
|
|
927
|
+
"paper folder: /w",
|
|
928
|
+
"artifact: gone.zip — NOT FOUND",
|
|
929
|
+
"to: osf project abcde",
|
|
930
|
+
"Name the paper folder and the file plainly (no cd, no $…), run the dry run, and ask then.",
|
|
931
|
+
].join("\n"),
|
|
932
|
+
);
|
|
933
|
+
// Guards: an upload naming no file or no project, a stray operand, or an unknown flag is unresolved.
|
|
934
|
+
[
|
|
935
|
+
"artifact upload --node abcde --save",
|
|
936
|
+
"artifact upload --to osf a.zip papers/p --save",
|
|
937
|
+
"artifact upload a.zip --node abcde p extra --save",
|
|
938
|
+
"artifact upload a.zip --node abcde --nope --save",
|
|
939
|
+
].forEach((c) => {
|
|
940
|
+
expect(withZip([], `npx paperlint ${c}`)).toMatch(
|
|
941
|
+
/could not resolve which PDF this send uploads/u,
|
|
942
|
+
);
|
|
943
|
+
});
|
|
944
|
+
});
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* PreToolUse on `Bash` (`plugin/hooks/hooks.json`): a command that sends a submission — `paperlint
|
|
4
4
|
* submission new|update` with `--save` or `--submit` — runs only when the person has said yes, in an
|
|
5
5
|
* `AskUserQuestion` asked since the last send, to a question naming the paper folder (its full path)
|
|
6
|
-
* and the sha256 of the PDF it sends.
|
|
6
|
+
* and the sha256 of the PDF it sends. An upload of the artifact, `paperlint artifact upload … --save`,
|
|
7
|
+
* is a send too: the question names the paper folder and the sha256 of the file it uploads.
|
|
7
8
|
* A command that names a portal's host runs only after a yes to a question naming that host and the
|
|
8
9
|
* command's first 60 characters. Without the yes the command is refused (`"permissionDecision":
|
|
9
10
|
* "deny"`), and the reason tells the agent exactly what to ask. Anything else: no output.
|
|
@@ -90,6 +91,8 @@ export type ConfirmDeps = PresetDeps & {
|
|
|
90
91
|
* `--pdf` the send names (null for the defaults), or null when they do not parse cleanly.
|
|
91
92
|
*/
|
|
92
93
|
readonly readSend: (words: readonly string[]) => Send | null;
|
|
94
|
+
/** The words after `artifact`, read the same way: the paper and the file an upload names, or null. */
|
|
95
|
+
readonly readUpload: (words: readonly string[]) => Upload | null;
|
|
93
96
|
};
|
|
94
97
|
|
|
95
98
|
/** What Claude Code reads from a PreToolUse hook's stdout to refuse the command; the agent sees the reason. */
|
|
@@ -129,22 +132,45 @@ function allLeaves(
|
|
|
129
132
|
];
|
|
130
133
|
}
|
|
131
134
|
|
|
132
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* Where a `paperlint artifact … upload … --save` stands in one command's words; -1 for none. The CLI
|
|
137
|
+
* reads the subcommand wherever the flags leave it (`artifact --to osf upload …`), so any `upload`
|
|
138
|
+
* after `artifact` counts here; `readUpload`, the CLI's own parser, then reads the words, and words
|
|
139
|
+
* it cannot read cleanly are refused rather than let through.
|
|
140
|
+
*/
|
|
141
|
+
const uploadAt = (l: ShellLeaf): number =>
|
|
142
|
+
l.hasFlag("save")
|
|
143
|
+
? l.args.findIndex(
|
|
144
|
+
(x, i) => x === "artifact" && l.args.slice(i + 1).includes("upload"),
|
|
145
|
+
)
|
|
146
|
+
: -1;
|
|
147
|
+
|
|
148
|
+
/** A `paperlint submission new|update` with `--save` or `--submit`, or an upload that saves, in the words of one command. */
|
|
133
149
|
function isSend(l: ShellLeaf): boolean {
|
|
134
150
|
const at = l.args.indexOf("submission");
|
|
135
151
|
return (
|
|
136
|
-
at >= 0 &&
|
|
137
|
-
|
|
138
|
-
|
|
152
|
+
(at >= 0 &&
|
|
153
|
+
l.args.slice(at + 1).some((w) => w === "new" || w === "update") &&
|
|
154
|
+
l.hasFlag("save", "submit")) ||
|
|
155
|
+
uploadAt(l) >= 0
|
|
139
156
|
);
|
|
140
157
|
}
|
|
141
158
|
|
|
142
|
-
/** One
|
|
159
|
+
/** One send: the paper folder and the `--pdf` a `submission new|update` names (null for the default). */
|
|
143
160
|
export interface Send {
|
|
144
161
|
readonly paper: string | null;
|
|
145
162
|
readonly pdf: string | null;
|
|
146
163
|
}
|
|
147
164
|
|
|
165
|
+
/** One `artifact upload --save`: the paper (null for the current folder), the file, and where it goes. */
|
|
166
|
+
export interface Upload {
|
|
167
|
+
readonly paper: string | null;
|
|
168
|
+
readonly artifact: string;
|
|
169
|
+
/** The host's name (`--to`) and the project on it (`--node`). */
|
|
170
|
+
readonly host: string;
|
|
171
|
+
readonly project: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
148
174
|
/** Programs that change the directory the rest of the command line runs in. */
|
|
149
175
|
const MOVES: ReadonlySet<string> = new Set(["cd", "pushd", "popd"]);
|
|
150
176
|
|
|
@@ -155,18 +181,25 @@ const MOVES: ReadonlySet<string> = new Set(["cd", "pushd", "popd"]);
|
|
|
155
181
|
*/
|
|
156
182
|
function sendsIn(
|
|
157
183
|
leaves: readonly ShellLeaf[],
|
|
158
|
-
|
|
159
|
-
): readonly (Send | null)[] {
|
|
184
|
+
deps: Pick<ConfirmDeps, "readSend" | "readUpload">,
|
|
185
|
+
): readonly (Send | Upload | null)[] {
|
|
160
186
|
return leaves.flatMap((l, n) => {
|
|
161
187
|
const at = l.args.findIndex(
|
|
162
188
|
(x, i) =>
|
|
163
189
|
x === "submission" && /^(?:new|update)$/u.test(l.args[i + 1] ?? ""),
|
|
164
190
|
);
|
|
165
|
-
|
|
191
|
+
const sends = at >= 0 && l.hasFlag("save", "submit");
|
|
192
|
+
const up = uploadAt(l);
|
|
193
|
+
if (!sends && up < 0) return [];
|
|
166
194
|
const moved = leaves
|
|
167
195
|
.slice(0, n + 1)
|
|
168
196
|
.some((x) => MOVES.has(x.head) || x.chdir !== null);
|
|
169
|
-
|
|
197
|
+
if (moved) return [null];
|
|
198
|
+
return [
|
|
199
|
+
sends
|
|
200
|
+
? deps.readSend(l.args.slice(at + 1))
|
|
201
|
+
: deps.readUpload(l.args.slice(up + 1)),
|
|
202
|
+
];
|
|
170
203
|
});
|
|
171
204
|
}
|
|
172
205
|
|
|
@@ -234,20 +267,47 @@ function factsLines(
|
|
|
234
267
|
return [...stale, bodyPages(f.value)];
|
|
235
268
|
}
|
|
236
269
|
|
|
237
|
-
/**
|
|
270
|
+
/**
|
|
271
|
+
* What a yes to one send must name: the paper folder as the hook resolves it, the file's sha256
|
|
272
|
+
* prefix, and, for an upload, the project it goes to.
|
|
273
|
+
*/
|
|
238
274
|
interface Named {
|
|
239
275
|
readonly folder: string;
|
|
240
276
|
readonly sha: string;
|
|
277
|
+
readonly project?: string;
|
|
241
278
|
}
|
|
242
279
|
|
|
243
280
|
/** One send, described: what a yes must name (null when the PDF is not found), and the lines for the person. */
|
|
244
281
|
interface Described {
|
|
245
282
|
readonly named: Named | null;
|
|
246
283
|
readonly lines: readonly string[];
|
|
284
|
+
/** An artifact upload, not a submission. */
|
|
285
|
+
readonly upload?: true;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** One upload, described: the paper, the file it uploads and its sha256, and where it goes. */
|
|
289
|
+
function describeUpload(u: Upload, cwd: string, files: Files): Described {
|
|
290
|
+
const paperDir = resolve(cwd, u.paper ?? ".");
|
|
291
|
+
const bytes = files.readBytes(callerPath(resolve(cwd, u.artifact)));
|
|
292
|
+
const sha = bytes === null ? null : sha256Hex(bytes).slice(0, SHA_SHOWN);
|
|
293
|
+
return {
|
|
294
|
+
upload: true,
|
|
295
|
+
named: sha === null ? null : { folder: paperDir, sha, project: u.project },
|
|
296
|
+
lines: [
|
|
297
|
+
`paper folder: ${paperDir}`,
|
|
298
|
+
`artifact: ${u.artifact}${sha === null ? " — NOT FOUND" : `, sha256 ${sha}`}`,
|
|
299
|
+
`to: ${u.host} project ${u.project}`,
|
|
300
|
+
],
|
|
301
|
+
};
|
|
247
302
|
}
|
|
248
303
|
|
|
249
304
|
/** One send, described: the paper, the PDF as the command resolves it, what the build saw. */
|
|
250
|
-
function describe(
|
|
305
|
+
function describe(
|
|
306
|
+
send: Send | Upload,
|
|
307
|
+
cwd: string,
|
|
308
|
+
deps: PresetDeps,
|
|
309
|
+
): Described {
|
|
310
|
+
if ("artifact" in send) return describeUpload(send, cwd, deps.files);
|
|
251
311
|
const paperDir = resolve(cwd, send.paper ?? ".");
|
|
252
312
|
const p = paperPreset(paperDir, deps);
|
|
253
313
|
const own = paperPdf(
|
|
@@ -277,6 +337,17 @@ const UNRESOLVED =
|
|
|
277
337
|
|
|
278
338
|
const NOT_SENT = "Not run: this sends the paper to the venue's portal";
|
|
279
339
|
const NAMES_PORTAL = "Not run: this command names a venue's submission portal";
|
|
340
|
+
const NOT_UPLOADED = "Not run: this uploads the paper's artifact to its host";
|
|
341
|
+
|
|
342
|
+
/** What to ask before an artifact upload. */
|
|
343
|
+
const HOW_TO_ASK_UPLOAD = [
|
|
344
|
+
"Ask the person with AskUserQuestion first, then run this command again. In the question, give the paper folder (the full path), the artifact's file and sha256, and the project, as written above.",
|
|
345
|
+
'Options: "Yes, upload it" and "No". One yes lets one upload through.',
|
|
346
|
+
].join("\n");
|
|
347
|
+
|
|
348
|
+
/** Whether every send of a command is an artifact upload: then it is asked about as one. */
|
|
349
|
+
const onlyUploads = (described: readonly Described[]): boolean =>
|
|
350
|
+
described.every((d) => d.upload === true);
|
|
280
351
|
|
|
281
352
|
/** What to ask, once every send's PDF is known. */
|
|
282
353
|
const HOW_TO_ASK = [
|
|
@@ -412,11 +483,11 @@ const literal = (text: string): string =>
|
|
|
412
483
|
text.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
413
484
|
|
|
414
485
|
/**
|
|
415
|
-
* Whether a question names
|
|
416
|
-
* (`/w/paper` is not `/w/paper2` or `/w/paper.old`), nor one it ends: the whole
|
|
486
|
+
* Whether a question names `word` (a folder, a project id) and not a longer one that starts with it
|
|
487
|
+
* (`/w/paper` is not `/w/paper2` or `/w/paper.old`), nor one it ends: the whole word, case-sensitive.
|
|
417
488
|
*/
|
|
418
|
-
const
|
|
419
|
-
new RegExp(`(?<![\\w.-])${literal(
|
|
489
|
+
const namesWhole = (question: string, word: string): boolean =>
|
|
490
|
+
new RegExp(`(?<![\\w.-])${literal(word)}(?![\\w.-])`, "u").test(question);
|
|
420
491
|
|
|
421
492
|
/** A question a yes must have been given to: what a send or a portal command needs it to name. */
|
|
422
493
|
type Needs = (question: string) => boolean;
|
|
@@ -441,11 +512,13 @@ function takeYes(
|
|
|
441
512
|
return found !== undefined && isYes(found) ? new Set([...taken, at]) : null;
|
|
442
513
|
}
|
|
443
514
|
|
|
444
|
-
/** What a yes to one send must name: its sha256 (any case)
|
|
515
|
+
/** What a yes to one send must name: its sha256 (any case), its folder (the whole path, as written) and its project. */
|
|
445
516
|
const namesSend =
|
|
446
517
|
(s: Named): Needs =>
|
|
447
518
|
(question) =>
|
|
448
|
-
hasAll(question, [s.sha]) &&
|
|
519
|
+
hasAll(question, [s.sha]) &&
|
|
520
|
+
namesWhole(question, s.folder) &&
|
|
521
|
+
(s.project === undefined || namesWhole(question, s.project));
|
|
449
522
|
|
|
450
523
|
/** What a yes to a command that names a portal must name: the host (any case) and the command's start, literally. */
|
|
451
524
|
const namesPortal =
|
|
@@ -478,18 +551,25 @@ function describedSends(
|
|
|
478
551
|
): readonly Described[] {
|
|
479
552
|
const sends = /[`$]/u.test(command)
|
|
480
553
|
? []
|
|
481
|
-
: sendsIn(deps.shellLeaves(command), deps
|
|
554
|
+
: sendsIn(deps.shellLeaves(command), deps);
|
|
482
555
|
return (sends.length === 0 ? [null] : sends).map((x): Described =>
|
|
483
556
|
x === null ? { named: null, lines: [UNRESOLVED] } : describe(x, cwd, deps),
|
|
484
557
|
);
|
|
485
558
|
}
|
|
486
559
|
|
|
487
560
|
/** The refusal of a send whose PDF is not known or not there: there is no sha256 to ask about. */
|
|
488
|
-
const noPdf = (described: readonly Described[]): readonly string[] =>
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
561
|
+
const noPdf = (described: readonly Described[]): readonly string[] =>
|
|
562
|
+
onlyUploads(described)
|
|
563
|
+
? [
|
|
564
|
+
`${NOT_UPLOADED}, and paperlint cannot find the file it uploads, so there is no sha256 to ask the person about.`,
|
|
565
|
+
...blocks(described),
|
|
566
|
+
"Name the paper folder and the file plainly (no cd, no $…), run the dry run, and ask then.",
|
|
567
|
+
]
|
|
568
|
+
: [
|
|
569
|
+
`${NOT_SENT}, and paperlint cannot find the PDF it uploads, so there is no sha256 to ask the person about.`,
|
|
570
|
+
...blocks(described),
|
|
571
|
+
"Name the paper folder and the PDF plainly (no cd, no $…), build the PDF, run the dry run, and ask then.",
|
|
572
|
+
];
|
|
493
573
|
|
|
494
574
|
/** The portal hosts the venue presets declare, or — when they cannot be read — none, and why. */
|
|
495
575
|
interface Hosts {
|
|
@@ -523,6 +603,17 @@ const fallbackLines = (h: Hosts): readonly string[] =>
|
|
|
523
603
|
`The venue presets could not be read (${h.failed}), so only HotCRP-hosted sites and paperlint sends are recognised until they are fixed.`,
|
|
524
604
|
];
|
|
525
605
|
|
|
606
|
+
/** How a refusal opens, and what it says to ask: a portal named, a paperlint send, or only uploads. */
|
|
607
|
+
function wordsFor(
|
|
608
|
+
paperlint: boolean,
|
|
609
|
+
described: readonly Described[],
|
|
610
|
+
): { readonly base: string; readonly ask: readonly string[] } {
|
|
611
|
+
if (!paperlint) return { base: NAMES_PORTAL, ask: [] };
|
|
612
|
+
return onlyUploads(described)
|
|
613
|
+
? { base: NOT_UPLOADED, ask: [HOW_TO_ASK_UPLOAD] }
|
|
614
|
+
: { base: NOT_SENT, ask: [HOW_TO_ASK] };
|
|
615
|
+
}
|
|
616
|
+
|
|
526
617
|
/**
|
|
527
618
|
* A command that sends: let through (null) when the person said yes to it since the last send —
|
|
528
619
|
* each paperlint send by its paper folder and its PDF's sha256, a yes of its own for each, a portal
|
|
@@ -537,7 +628,7 @@ function decide(
|
|
|
537
628
|
const described = c.paperlint ? describedSends(c.text, c.cwd, deps) : [];
|
|
538
629
|
const named = described.flatMap((d) => (d.named === null ? [] : [d.named]));
|
|
539
630
|
if (named.length < described.length) return noPdf(described);
|
|
540
|
-
const base = c.paperlint
|
|
631
|
+
const { base, ask } = wordsFor(c.paperlint, described);
|
|
541
632
|
const read = transcriptOf(payload, deps.files);
|
|
542
633
|
if (typeof read !== "string")
|
|
543
634
|
return [
|
|
@@ -550,7 +641,7 @@ function decide(
|
|
|
550
641
|
return [
|
|
551
642
|
`${base}, and the person has not said yes to it since the last send.`,
|
|
552
643
|
...blocks(described),
|
|
553
|
-
...
|
|
644
|
+
...ask,
|
|
554
645
|
...portalLines(c.host, start),
|
|
555
646
|
];
|
|
556
647
|
}
|
|
@@ -573,7 +664,9 @@ function earlierSend(
|
|
|
573
664
|
mayHold: (text) => {
|
|
574
665
|
const plain = text.replace(/["'\\]/gu, "").toLowerCase();
|
|
575
666
|
return (
|
|
576
|
-
plain.includes("submission") ||
|
|
667
|
+
plain.includes("submission") ||
|
|
668
|
+
plain.includes("artifact") ||
|
|
669
|
+
known.some((h) => plain.includes(h))
|
|
577
670
|
);
|
|
578
671
|
},
|
|
579
672
|
sends: (command) => {
|
|
@@ -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
|
-
|
|
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
|
+
});
|