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
package/src/cli.ts CHANGED
@@ -24,7 +24,14 @@
24
24
  * replaced it: silently breaking someone else's workflow is worse than asking them to fix a line.
25
25
  */
26
26
  import { ESLint, type Linter } from "eslint";
27
- import { readFileSync, readdirSync, existsSync, statSync } from "node:fs";
27
+ import {
28
+ readFileSync,
29
+ readdirSync,
30
+ existsSync,
31
+ realpathSync,
32
+ statSync,
33
+ } from "node:fs";
34
+ import { absolutePath } from "./domain/paths.ts";
28
35
  import { createRequire } from "node:module";
29
36
  import { stripVTControlCharacters } from "node:util";
30
37
  import { spawnSync } from "node:child_process";
@@ -155,6 +162,8 @@ import { doctor } from "./doctor.ts";
155
162
  import {
156
163
  askOnTerminal,
157
164
  askOrDefault,
165
+ CANCELLED_CODE,
166
+ CANCELLED_LINE,
158
167
  init,
159
168
  processInteractivity,
160
169
  } from "./init.ts";
@@ -233,7 +242,19 @@ import {
233
242
  recordTold,
234
243
  } from "./hooks-notice.ts";
235
244
  import { unwiredHooks } from "./hooks-settings.ts";
236
- import { linkSkills, unlinkedSkills, type LinkReport } from "./link-skills.ts";
245
+ import {
246
+ linkSkills,
247
+ locatePackage,
248
+ unlinkedSkills,
249
+ type LinkReport,
250
+ } from "./link-skills.ts";
251
+ import { projectInstall } from "./adapters/package-manager/index.ts";
252
+ import type { ProjectInstall } from "./ports/project-install.ts";
253
+ import {
254
+ selfInstallStep,
255
+ versionOf,
256
+ type SelfInstallDeps,
257
+ } from "./self-install.ts";
237
258
  import {
238
259
  lintEditedHook,
239
260
  type LintResult,
@@ -308,10 +329,12 @@ const USAGE = `paperlint — machine-checkable gates for a paper kept in git
308
329
  npx paperlint submission show [paper]
309
330
  the paper's submission on the venue's portal: status, title,
310
331
  type, topics, abstract length, the PDF the portal holds, and
311
- whether it is the local paper.pdf (sha256)
332
+ whether it is the local paper.pdf (sha256); flags a title,
333
+ abstract or authors that are not the paper's
312
334
  npx paperlint submission update [paper] [--pdf <file>] [--abstract <file>] [--submit] [--save]
313
- send the PDF (default: the paper's own), an abstract, or
314
- "submitted". A DRY RUN unless --save: the portal checks the
335
+ send the PDF (default: the paper's own), the paper's title
336
+ and abstract each when the portal holds another (--abstract:
337
+ that file's text instead), or "submitted". A DRY RUN unless --save: the portal checks the
315
338
  change and keeps nothing. First prints what the venue rules find
316
339
  in that exact PDF, as lint does; --save refuses a PDF the last
317
340
  build did not measure (exit 2)
@@ -2379,7 +2402,13 @@ async function runInit(
2379
2402
  log,
2380
2403
  err,
2381
2404
  cwd,
2382
- }: { log: typeof console.log; err: typeof console.error; cwd: string },
2405
+ install,
2406
+ }: {
2407
+ log: typeof console.log;
2408
+ err: typeof console.error;
2409
+ cwd: string;
2410
+ install: ProjectInstall;
2411
+ },
2383
2412
  ): Promise<number> {
2384
2413
  // Deferred, not implemented: named and refused, rather than read as the directory argument.
2385
2414
  if (a.hooksMode !== null) {
@@ -2389,10 +2418,22 @@ async function runInit(
2389
2418
  );
2390
2419
  return 2;
2391
2420
  }
2421
+ // Loaded here, not at the top: every hook runs through this file, and none of them asks anything.
2422
+ const { clackPrompts } = await import("./adapters/clack/index.ts");
2423
+ const prompts = clackPrompts();
2424
+ // Step 0, before init: paperlint itself, in the project's devDependencies (`self-install.ts`).
2425
+ const stop = await selfInstallStep(
2426
+ absolutePath(resolve(cwd, a.paths[0] ?? ".")),
2427
+ selfInstallDeps(install),
2428
+ { prompts, interactive: processInteractivity(a.yes).interactive, log },
2429
+ { code: CANCELLED_CODE, line: CANCELLED_LINE },
2430
+ );
2431
+ if (stop !== null) return stop;
2392
2432
  return await init(a.paths[0] ?? ".", {
2393
2433
  log,
2394
2434
  err,
2395
2435
  cwd,
2436
+ prompts,
2396
2437
  yes: a.yes,
2397
2438
  hooks: !a.noHooks,
2398
2439
  paper: a.paper,
@@ -2405,6 +2446,35 @@ async function runInit(
2405
2446
  });
2406
2447
  }
2407
2448
 
2449
+ /** This copy of paperlint: its real directory and its version. */
2450
+ const runningCopy = (): { readonly dir: string; readonly version: string } => ({
2451
+ dir: realpathSync(fileURLToPath(new URL("..", import.meta.url))),
2452
+ version: packageVersion(),
2453
+ });
2454
+
2455
+ /**
2456
+ * What `init` needs to add paperlint to a project. `PAPERLINT_INSTALL_SPEC` replaces what is added
2457
+ * (a tarball, for the install e2e: an unreleased build's version is on no registry).
2458
+ */
2459
+ const selfInstallDeps = (install: ProjectInstall): SelfInstallDeps => {
2460
+ const running = runningCopy();
2461
+ return {
2462
+ running,
2463
+ installed: (root) => {
2464
+ const at = locatePackage(root);
2465
+ if ("error" in at) return null;
2466
+ const version = versionOf(
2467
+ nodeFiles.readBytes(absolutePath(join(at.dir, "package.json"))),
2468
+ );
2469
+ return version === null ? null : { dir: at.dir, version };
2470
+ },
2471
+ files: nodeFiles,
2472
+ install,
2473
+ spec:
2474
+ process.env["PAPERLINT_INSTALL_SPEC"] ?? `paperlint@${running.version}`,
2475
+ };
2476
+ };
2477
+
2408
2478
  /** The LaTeX language, loaded when a lint needs it: only `lint` and the `lint-edited` hook do. */
2409
2479
  const loadLatexLanguage = async (): Promise<unknown> =>
2410
2480
  (await import("#eslint-rules/latex-language")).texLanguage;
@@ -2419,10 +2489,13 @@ export async function run(
2419
2489
  checkReferences = onlineReferences,
2420
2490
  loadTexLanguage = loadLatexLanguage,
2421
2491
  skillLinks = readSkillLinks,
2492
+ install = projectInstall,
2422
2493
  }: {
2423
2494
  log?: typeof console.log;
2424
2495
  err?: typeof console.error;
2425
2496
  cwd?: string;
2497
+ /** How `init` adds paperlint to a project: the package manager by default; a test hands a fake. */
2498
+ install?: ProjectInstall;
2426
2499
  /** The clock `lint` times itself with, in milliseconds; a test hands one that answers fixed values. */
2427
2500
  now?: () => number;
2428
2501
  /**
@@ -2464,7 +2537,7 @@ export async function run(
2464
2537
  // `init` asks the CLI's OWN reader what it would lint, so the two sides `doctor` compares are
2465
2538
  // not two implementations of the same question. A second resolver here is the defect the
2466
2539
  // comparison exists to catch.
2467
- if (a.cmd === "init") return await runInit(a, { log, err, cwd });
2540
+ if (a.cmd === "init") return await runInit(a, { log, err, cwd, install });
2468
2541
  // `doctor` reads the config but must NOT die on a broken one — reporting that the config is
2469
2542
  // broken is precisely its job. So a failed read becomes "the CLI would lint nothing", which is
2470
2543
  // what it prints, rather than an early exit that tells the reader nothing about the hooks.
@@ -86,6 +86,8 @@ export interface SubmissionView {
86
86
  readonly paperType: string | null;
87
87
  readonly topics: readonly string[];
88
88
  readonly abstract: string | null;
89
+ /** The authors the portal records, in its order; null when it does not say. */
90
+ readonly authors: readonly Author[] | null;
89
91
  /** The PDF the portal holds; null when none is uploaded. */
90
92
  readonly pdf: PortalDocument | null;
91
93
  /** Unix seconds; null when not submitted or not said. */
@@ -98,6 +100,8 @@ export interface SubmissionView {
98
100
  /** A change to send. Every absent part is left as the portal has it. */
99
101
  export interface SubmissionChange {
100
102
  readonly pdf: { readonly name: string; readonly bytes: Uint8Array } | null;
103
+ /** The paper's title, sent when it differs from the portal's; null leaves the portal's. */
104
+ readonly title: string | null;
101
105
  readonly abstract: string | null;
102
106
  /** Mark the submission submitted (ready for review). */
103
107
  readonly submit: boolean;
package/src/init.test.ts CHANGED
@@ -18,12 +18,14 @@ import {
18
18
  writeFileSync,
19
19
  } from "node:fs";
20
20
  import { tmpdir } from "node:os";
21
- import { join } from "node:path";
21
+ import { join, relative } from "node:path";
22
22
  import { afterEach, describe, expect, it } from "vitest";
23
23
  import { FRESH_CLONE_NOTE } from "./hooks-settings.ts";
24
24
  import { load as yamlLoad } from "js-yaml";
25
25
  import { z } from "zod";
26
26
  import {
27
+ CANCELLED_CODE,
28
+ CANCELLED_LINE,
27
29
  WORKFLOW_PATH,
28
30
  choosePapers,
29
31
  declarePapers,
@@ -36,7 +38,7 @@ import {
36
38
  reportWorkflow,
37
39
  workflowYaml,
38
40
  } from "./init.ts";
39
- import { runNode } from "../test/support.ts";
41
+ import { runNode, scriptedPrompts, type Reply } from "../test/support.ts";
40
42
  import { nodeFiles } from "./adapters/node/index.ts";
41
43
  import { presetsDir } from "./package-dirs.ts";
42
44
  import { shippedVenueNames } from "./presets.ts";
@@ -94,24 +96,29 @@ describe("paperlint init — a declared papers directory", () => {
94
96
 
95
97
  it("is not asked about, even with a human at the terminal", async () => {
96
98
  const root = project();
97
- const asked: string[] = [];
99
+ const prompts = scriptedPrompts(() => false);
98
100
  await init(root, {
99
101
  cwd: root,
100
102
  log: () => {},
101
103
  err: () => {},
102
104
  interactive: true,
103
- ask: (q) => Promise.resolve((asked.push(q), "n")),
105
+ prompts,
104
106
  hooks: false,
105
107
  run: () => ({ status: 0 }),
106
108
  link: () => ({ ok: false, error: "not linked in this test" }),
107
109
  });
108
- expect(asked.filter((q) => /papers roots/.test(q))).toEqual([]);
110
+ expect(prompts.asked).toEqual([
111
+ "add a GitHub Actions workflow that runs this in CI?",
112
+ ]);
109
113
  });
110
114
 
111
115
  it("without a declaration, the candidates are still measured and offered", async () => {
112
116
  const choice = await choosePapers(project(), { interactive: false });
113
- expect(choice.how).toBe("not-asked");
114
- expect(choice.candidates.length).toBeGreaterThan(1);
117
+ expect(choice).toEqual({
118
+ papers: "drafts",
119
+ how: "not-asked",
120
+ candidates: ["drafts", "eslint-rules/fixtures", "papers"],
121
+ });
115
122
  });
116
123
  });
117
124
 
@@ -161,25 +168,26 @@ describe("paperlint init — writes paperlint.json only when something differs f
161
168
  /** Runs init in a fresh directory with the given TeX Live port; what it printed and asked. */
162
169
  const texRun = async (
163
170
  tex: { installed: () => boolean; install?: () => number },
164
- { interactive, answer = "" }: { interactive: boolean; answer?: string },
171
+ { interactive, answer }: { interactive: boolean; answer?: Reply },
165
172
  ) => {
166
173
  const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-tex-")));
167
174
  dirs.push(root);
168
175
  const out: string[] = [];
169
- const asked: string[] = [];
170
- await init(root, {
176
+ const prompts = scriptedPrompts((q) =>
177
+ /TeX Live/.test(q) ? answer : undefined,
178
+ );
179
+ const code = await init(root, {
171
180
  cwd: root,
172
181
  log: (s: string) => out.push(s),
173
182
  err: () => {},
174
183
  interactive,
175
- ask: (q) =>
176
- Promise.resolve((asked.push(q), /TeX Live/.test(q) ? answer : "")),
184
+ prompts,
177
185
  hooks: false,
178
186
  run: () => ({ status: 0 }),
179
187
  link: () => ({ ok: false as const, error: "not linked in this test" }),
180
188
  tex,
181
189
  });
182
- return { text: out.join("\n"), asked };
190
+ return { text: out.join("\n"), asked: prompts.asked, code };
183
191
  };
184
192
 
185
193
  describe("paperlint init — TeX Live is offered with its cost, never installed unasked", () => {
@@ -201,10 +209,10 @@ describe("paperlint init — TeX Live is offered with its cost, never installed
201
209
  let installs = 0;
202
210
  const r = await texRun(
203
211
  { installed: () => false, install: () => (installs++, 0) },
204
- { interactive: true, answer: "y" },
212
+ { interactive: true, answer: true },
205
213
  );
206
- expect(r.asked.find((q) => /TeX Live/.test(q))).toMatch(
207
- /~270 MB, ~3 min, once\) \[y\/N\]/,
214
+ expect(r.asked.find((q) => /TeX Live/.test(q))).toBe(
215
+ "install TeX Live now, for `paperlint build`? (~270 MB, ~3 min, once)",
208
216
  );
209
217
  expect(installs).toBe(1);
210
218
  expect(r.text).not.toMatch(/next: .*\n.*npx paperlint toolchain/);
@@ -220,10 +228,24 @@ describe("paperlint init — TeX Live is offered with its cost, never installed
220
228
  expect(r.text).toMatch(/declined — nothing installed/);
221
229
  });
222
230
 
231
+ it("🔴 Ctrl+C at the question installs nothing, stops init and exits 130", async () => {
232
+ let installs = 0;
233
+ const r = await texRun(
234
+ { installed: () => false, install: () => (installs++, 0) },
235
+ { interactive: true, answer: "cancel" },
236
+ );
237
+ expect([installs, r.code, r.text.split("\n").at(-1)]).toEqual([
238
+ 0,
239
+ CANCELLED_CODE,
240
+ CANCELLED_LINE,
241
+ ]);
242
+ expect(r.text).not.toMatch(/paperlint doctor/);
243
+ });
244
+
223
245
  it("already installed: not asked about", async () => {
224
246
  const r = await texRun(
225
247
  { installed: () => true, install: () => 0 },
226
- { interactive: true, answer: "y" },
248
+ { interactive: true, answer: true },
227
249
  );
228
250
  expect(r.asked.filter((q) => /TeX Live/.test(q))).toEqual([]);
229
251
  expect(r.text).toMatch(/✓ paperlint's TeX Live is installed/);
@@ -327,13 +349,29 @@ describe("paperlint init — how several candidate directories were decided, sai
327
349
  out.slice(out.indexOf("papers directory") + 1, out.indexOf("settings") - 1);
328
350
 
329
351
  it("picked by a human", async () => {
330
- const r = await initRun(several(), {
331
- interactive: true,
332
- ask: () => Promise.resolve("2"),
333
- });
352
+ const prompts = scriptedPrompts((q) =>
353
+ /papers roots/.test(q) ? "writing" : false,
354
+ );
355
+ const r = await initRun(several(), { interactive: true, prompts });
334
356
  expect(section(r.out)).toEqual([
335
357
  " ✓ writing — you picked it out of 2 candidates",
336
358
  ]);
359
+ expect(prompts.asked[0]).toBe(
360
+ "several directories look like papers roots — which one?",
361
+ );
362
+ });
363
+
364
+ it("🔴 Ctrl+C at the choice writes no paperlint.json and exits 130", async () => {
365
+ const root = several();
366
+ const r = await initRun(root, {
367
+ interactive: true,
368
+ prompts: scriptedPrompts(() => "cancel"),
369
+ });
370
+ expect([r.code, r.out.slice(2)]).toEqual([
371
+ CANCELLED_CODE,
372
+ [CANCELLED_LINE],
373
+ ]);
374
+ expect(existsSync(join(root, "paperlint.json"))).toBe(false);
337
375
  });
338
376
 
339
377
  it("no terminal: the first, and the others named", async () => {
@@ -344,10 +382,12 @@ describe("paperlint init — how several candidate directories were decided, sai
344
382
  ]);
345
383
  });
346
384
 
347
- it("an answer that picks nothing: the first, and said so", async () => {
385
+ it("a question that failed (the stream ended): the first, and said so", async () => {
348
386
  const r = await initRun(several(), {
349
387
  interactive: true,
350
- ask: () => Promise.resolve("nine"),
388
+ prompts: scriptedPrompts((q) =>
389
+ /papers roots/.test(q) ? new Error("stream ended") : false,
390
+ ),
351
391
  });
352
392
  expect(section(r.out)[0]).toBe(
353
393
  " ✓ drafts — 2 candidates, no answer was given, so the first one was taken",
@@ -479,7 +519,7 @@ describe("paperlint init — TeX Live and hooks failures, whole", () => {
479
519
  it("TeX Live: a failed install says to run it again", async () => {
480
520
  const t = await offerTexLive(
481
521
  { installed: () => false, install: () => 1 },
482
- { interactive: true, ask: () => Promise.resolve("yes") },
522
+ { interactive: true, prompts: scriptedPrompts(() => true) },
483
523
  );
484
524
  expect([t, reportTexLive(t, "")]).toEqual([
485
525
  "failed",
@@ -501,6 +541,26 @@ describe("paperlint init — TeX Live and hooks failures, whole", () => {
501
541
  });
502
542
  expect(outcome).toEqual({ status: "failed", reason: "merge exploded" });
503
543
  });
544
+
545
+ it("hooks: a question that failed (the stream ended) takes the stated default, YES; a No declines", async () => {
546
+ const ask = async (reply: boolean | Error) => {
547
+ const root = tree({});
548
+ const outcome = await offerHooks(root, {
549
+ hooks: true,
550
+ interactive: true,
551
+ prompts: scriptedPrompts(() => reply),
552
+ });
553
+ // Each run has its own temp root: compare where it wrote, relative to that root.
554
+ return "path" in outcome
555
+ ? { ...outcome, path: relative(root, outcome.path) }
556
+ : outcome;
557
+ };
558
+ // Guards: the failed question wires exactly what an explicit yes wires, not a decline.
559
+ expect([await ask(new Error("stream ended")), await ask(false)]).toEqual([
560
+ await ask(true),
561
+ { status: "declined" },
562
+ ]);
563
+ });
504
564
  });
505
565
 
506
566
  describe("paperlint init — a first paper", () => {
@@ -508,7 +568,7 @@ describe("paperlint init — a first paper", () => {
508
568
  const made: string[] = [];
509
569
  const r = await initRun(tree({}), {
510
570
  interactive: true,
511
- ask: () => Promise.resolve(""),
571
+ prompts: scriptedPrompts((q) => (/first paper/.test(q) ? "" : false)),
512
572
  createPaper: (_root, name) => Promise.resolve((made.push(name), 0)),
513
573
  });
514
574
  expect(made).toEqual([]);
@@ -516,17 +576,68 @@ describe("paperlint init — a first paper", () => {
516
576
  " · none yet. `npx paperlint new <name>` or `--paper <name>` creates one",
517
577
  );
518
578
  });
579
+
580
+ it("a name typed at the prompt creates that paper", async () => {
581
+ const made: string[] = [];
582
+ await initRun(tree({}), {
583
+ interactive: true,
584
+ prompts: scriptedPrompts((q) =>
585
+ /first paper/.test(q) ? " draft-one " : false,
586
+ ),
587
+ createPaper: (_root, name) => Promise.resolve((made.push(name), 0)),
588
+ });
589
+ expect(made).toEqual(["draft-one"]);
590
+ });
591
+
592
+ it("🔴 Ctrl+C at the name creates nothing and exits 130", async () => {
593
+ const made: string[] = [];
594
+ const r = await initRun(tree({}), {
595
+ interactive: true,
596
+ prompts: scriptedPrompts((q) =>
597
+ /first paper/.test(q) ? "cancel" : false,
598
+ ),
599
+ createPaper: (_root, name) => Promise.resolve((made.push(name), 0)),
600
+ });
601
+ expect([made, r.code, r.out.at(-1)]).toEqual([
602
+ [],
603
+ CANCELLED_CODE,
604
+ CANCELLED_LINE,
605
+ ]);
606
+ });
607
+ });
608
+
609
+ describe("paperlint init — Ctrl+C at the hooks or the workflow question", () => {
610
+ it("🔴 at the hooks: nothing is wired, and nothing after it is asked", async () => {
611
+ const root = tree({});
612
+ const prompts = scriptedPrompts(() => "cancel");
613
+ const r = await initRun(root, { interactive: true, hooks: true, prompts });
614
+ expect([r.code, r.out.at(-1), prompts.asked.length]).toEqual([
615
+ CANCELLED_CODE,
616
+ CANCELLED_LINE,
617
+ 1,
618
+ ]);
619
+ expect(existsSync(join(root, ".claude", "settings.json"))).toBe(false);
620
+ });
621
+
622
+ it("🔴 at the workflow: no file, exit 130", async () => {
623
+ const root = tree({});
624
+ const r = await initRun(root, {
625
+ interactive: true,
626
+ prompts: scriptedPrompts(() => "cancel"),
627
+ });
628
+ expect([r.code, r.out.at(-1)]).toEqual([CANCELLED_CODE, CANCELLED_LINE]);
629
+ expect(existsSync(join(root, WORKFLOW_PATH))).toBe(false);
630
+ });
519
631
  });
520
632
 
521
633
  describe("paperlint init — a first paper named after a venue", () => {
522
634
  it("--paper aisec-2026 is refused before anything is asked, and createPaper is not called", async () => {
523
635
  const made: string[] = [];
524
- const asked: string[] = [];
525
636
  const r = await initRun(tree({}), {
526
637
  interactive: true,
527
638
  paper: "aisec-2026",
528
639
  venues: shippedVenueNames({ files: nodeFiles, venuesDir: presetsDir() }),
529
- ask: (q) => Promise.resolve((asked.push(q), "")),
640
+ prompts: scriptedPrompts(() => false),
530
641
  createPaper: (_root, name) => Promise.resolve((made.push(name), 0)),
531
642
  });
532
643
  expect(made).toEqual([]);