paperlint 19.0.0 → 19.0.2
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-plugin/plugin.json +1 -1
- package/CLAUDE.md +2 -2
- package/dist/adapters/eslint/index.d.ts +13 -0
- package/dist/adapters/eslint/index.d.ts.map +1 -0
- package/dist/adapters/eslint/index.js +44 -0
- package/dist/adapters/eslint/index.js.map +1 -0
- package/dist/adapters/eslint/report.io.d.ts +15 -0
- package/dist/adapters/eslint/report.io.d.ts.map +1 -0
- package/dist/adapters/eslint/report.io.js +48 -0
- package/dist/adapters/eslint/report.io.js.map +1 -0
- package/dist/cli.d.ts +7 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +80 -121
- package/dist/cli.js.map +1 -1
- package/dist/domain/submission-lint.d.ts +29 -0
- package/dist/domain/submission-lint.d.ts.map +1 -0
- package/dist/domain/submission-lint.js +84 -0
- package/dist/domain/submission-lint.js.map +1 -0
- package/dist/folder-layout-hook.js +1 -1
- package/dist/hooks-notice.d.ts +2 -0
- package/dist/hooks-notice.d.ts.map +1 -1
- package/dist/hooks-notice.js +4 -1
- package/dist/hooks-notice.js.map +1 -1
- package/dist/ports/submission-lint.d.ts +6 -0
- package/dist/ports/submission-lint.d.ts.map +1 -0
- package/dist/ports/submission-lint.js +2 -0
- package/dist/ports/submission-lint.js.map +1 -0
- package/dist/structure.d.ts +17 -1
- package/dist/structure.d.ts.map +1 -1
- package/dist/structure.js.map +1 -1
- package/dist/submission-confirm-hook.d.ts +8 -1
- package/dist/submission-confirm-hook.d.ts.map +1 -1
- package/dist/submission-confirm-hook.js +75 -20
- package/dist/submission-confirm-hook.js.map +1 -1
- package/dist/submission.d.ts +5 -0
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +46 -7
- package/dist/submission.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/install.md +4 -4
- package/docs/layout.md +0 -1
- package/docs/submission.md +19 -8
- package/eslint.config.mjs +2 -0
- package/hooks/hooks.harness.ts +2 -140
- package/hooks/paper-skills-nudge.hook.mjs +0 -6
- package/lib/paper-config.harness.mjs +1 -2
- package/package.json +1 -1
- package/plugin/hooks/hooks.json +0 -9
- package/scripts/eslint-file-length.mjs +117 -0
- package/src/adapters/eslint/index.test.ts +152 -0
- package/src/adapters/eslint/index.ts +89 -0
- package/src/adapters/eslint/report.io.ts +82 -0
- package/src/cli.harness.mjs +9 -8
- package/src/cli.test.ts +4 -4
- package/src/cli.ts +110 -144
- package/src/domain/submission-lint.test.ts +211 -0
- package/src/domain/submission-lint.ts +166 -0
- package/src/folder-layout-hook.ts +1 -1
- package/src/hooks-notice.test.ts +2 -2
- package/src/hooks-notice.ts +10 -1
- package/src/hooks-settings.harness.ts +8 -8
- package/src/ports/submission-lint.ts +10 -0
- package/src/structure.ts +2 -4
- package/src/submission-confirm-hook-lint.test.ts +47 -0
- package/src/submission-confirm-hook.test.ts +73 -6
- package/src/submission-confirm-hook.ts +133 -28
- package/src/submission-fields-run.test.ts +1 -1
- package/src/submission-new.test.ts +4 -2
- package/src/submission-update.test.ts +16 -11
- package/src/submission.ts +62 -8
- package/src/types.ts +2 -0
- package/hooks/paper-status-gates.hook.mjs +0 -158
- package/hooks/paper-status-gates.sh +0 -93
- package/hooks/paper-status-gates.test.ts +0 -101
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { partition } from "remeda";
|
|
2
|
+
import type { PaperSource, Segment } from "./paper-source.ts";
|
|
3
|
+
import type { Outline, Span } from "./tex-document.ts";
|
|
4
|
+
|
|
5
|
+
export interface LintFinding {
|
|
6
|
+
readonly file: string;
|
|
7
|
+
readonly severity: 1 | 2;
|
|
8
|
+
readonly line?: number | undefined;
|
|
9
|
+
readonly column?: number | undefined;
|
|
10
|
+
readonly ruleId: string | null;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
readonly fatal?: boolean | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SubmissionLint {
|
|
16
|
+
readonly errors: readonly LintFinding[];
|
|
17
|
+
readonly warnings: readonly LintFinding[];
|
|
18
|
+
readonly abstractWarnings: readonly LintFinding[];
|
|
19
|
+
readonly introductionWarnings: readonly LintFinding[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface PaperSections {
|
|
23
|
+
readonly paper: PaperSource;
|
|
24
|
+
readonly abstract: Span | null;
|
|
25
|
+
readonly outline: Outline;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const introductionNames: ReadonlySet<string> = new Set([
|
|
29
|
+
"introduction",
|
|
30
|
+
"intro",
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
function introductionOf({ sections, backMatter, end }: Outline): Span | null {
|
|
34
|
+
const headings = sections.flatMap(({ place, title }) =>
|
|
35
|
+
place.kind === "at" ? [{ start: place.span.start, title }] : [],
|
|
36
|
+
);
|
|
37
|
+
const at = headings.findIndex(({ title }) =>
|
|
38
|
+
introductionNames.has(title.toLowerCase().split(" ", 1).join("")),
|
|
39
|
+
);
|
|
40
|
+
const heading = headings[at];
|
|
41
|
+
if (heading === undefined) return null;
|
|
42
|
+
return {
|
|
43
|
+
start: heading.start,
|
|
44
|
+
end: Math.min(
|
|
45
|
+
headings[at + 1]?.start ?? Infinity,
|
|
46
|
+
backMatter ?? end ?? Infinity,
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function offsetOf(
|
|
52
|
+
source: string,
|
|
53
|
+
{ line, column }: LintFinding,
|
|
54
|
+
): number | null {
|
|
55
|
+
if (line === undefined || line < 1) return null;
|
|
56
|
+
const lines = source.split("\n");
|
|
57
|
+
if (line > lines.length) return null;
|
|
58
|
+
return (
|
|
59
|
+
lines
|
|
60
|
+
.slice(0, line - 1)
|
|
61
|
+
.reduce((offset, text) => offset + text.length + 1, 0) +
|
|
62
|
+
(column ?? 1) -
|
|
63
|
+
1
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const contains = ({ start, end }: Span, offset: number): boolean =>
|
|
68
|
+
start <= offset && offset < end;
|
|
69
|
+
|
|
70
|
+
const onlySectionText = (text: string, section: Span, s: Segment): boolean =>
|
|
71
|
+
!text.slice(s.start, Math.min(s.end, section.start)).trim() &&
|
|
72
|
+
!text.slice(Math.max(s.start, section.end), s.end).trim();
|
|
73
|
+
|
|
74
|
+
/** Given ESLint's structured location, recover the assembled position or its outer include. */
|
|
75
|
+
function inSection(
|
|
76
|
+
paper: PaperSource,
|
|
77
|
+
finding: LintFinding,
|
|
78
|
+
section: Span,
|
|
79
|
+
): boolean {
|
|
80
|
+
const source = paper.segments.find((s) => s.file === finding.file)?.source;
|
|
81
|
+
const offset = source === undefined ? null : offsetOf(source, finding);
|
|
82
|
+
if (offset === null) return false;
|
|
83
|
+
const included = paper.segments.filter(
|
|
84
|
+
(s) =>
|
|
85
|
+
finding.file === paper.main && s.via !== null && contains(s.via, offset),
|
|
86
|
+
);
|
|
87
|
+
// An include can hold more than one section. Its anchor alone cannot decide which warned.
|
|
88
|
+
if (included.length > 0)
|
|
89
|
+
return (
|
|
90
|
+
included.some((s) => s.start < section.end && s.end > section.start) &&
|
|
91
|
+
included.every((s) => onlySectionText(paper.text, section, s))
|
|
92
|
+
);
|
|
93
|
+
return paper.segments.some(
|
|
94
|
+
(s) =>
|
|
95
|
+
s.file === finding.file &&
|
|
96
|
+
offset >= s.from &&
|
|
97
|
+
offset < s.from + s.end - s.start &&
|
|
98
|
+
contains(section, s.start + offset - s.from),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function submissionLint(
|
|
103
|
+
findings: readonly LintFinding[],
|
|
104
|
+
sections: PaperSections | null,
|
|
105
|
+
): SubmissionLint {
|
|
106
|
+
const [warnings, errors] = partition(findings, (m) => m.severity === 1);
|
|
107
|
+
const inSpan = (span: Span | null) =>
|
|
108
|
+
sections === null || span === null
|
|
109
|
+
? []
|
|
110
|
+
: warnings.filter((m) => inSection(sections.paper, m, span));
|
|
111
|
+
return {
|
|
112
|
+
errors,
|
|
113
|
+
warnings,
|
|
114
|
+
abstractWarnings: inSpan(sections?.abstract ?? null),
|
|
115
|
+
introductionWarnings: inSpan(
|
|
116
|
+
sections === null ? null : introductionOf(sections.outline),
|
|
117
|
+
),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export const lintFindingLine = (m: LintFinding): string => {
|
|
122
|
+
const place = m.line
|
|
123
|
+
? `${m.file}:${String(m.line)}:${String(m.column ?? 1)}`
|
|
124
|
+
: m.file;
|
|
125
|
+
return `${place}${m.ruleId === null ? "" : ` ${m.ruleId}`} — ${m.message.trim()}`;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const count = (n: number, noun: string): string =>
|
|
129
|
+
`${String(n)} ${noun}${n === 1 ? "" : "s"}`;
|
|
130
|
+
|
|
131
|
+
export const lintSummary = (lint: SubmissionLint): string =>
|
|
132
|
+
`lint: ${count(lint.errors.length, "error")}, ${count(lint.warnings.length, "warning")} (abstract: ${String(lint.abstractWarnings.length)}, introduction: ${String(lint.introductionWarnings.length)})`;
|
|
133
|
+
|
|
134
|
+
const block = (
|
|
135
|
+
title: string,
|
|
136
|
+
findings: readonly LintFinding[],
|
|
137
|
+
): readonly string[] =>
|
|
138
|
+
findings.length === 0
|
|
139
|
+
? []
|
|
140
|
+
: [title, ...findings.map((m) => ` ${lintFindingLine(m)}`)];
|
|
141
|
+
|
|
142
|
+
export const lintReportLines = (lint: SubmissionLint): readonly string[] => [
|
|
143
|
+
lintSummary(lint),
|
|
144
|
+
...block("Abstract warnings", lint.abstractWarnings),
|
|
145
|
+
...block("Introduction warnings", lint.introductionWarnings),
|
|
146
|
+
...block("Lint errors", lint.errors),
|
|
147
|
+
...block(
|
|
148
|
+
"Other lint warnings",
|
|
149
|
+
lint.warnings.filter(
|
|
150
|
+
(m) =>
|
|
151
|
+
!lint.abstractWarnings.includes(m) &&
|
|
152
|
+
!lint.introductionWarnings.includes(m),
|
|
153
|
+
),
|
|
154
|
+
),
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
export const lintExceptionReason = (reason: string): string =>
|
|
158
|
+
`Allow lint errors: ${JSON.stringify(reason.trim())}`;
|
|
159
|
+
|
|
160
|
+
export const lintExceptionLines = (
|
|
161
|
+
lint: SubmissionLint,
|
|
162
|
+
reason: string,
|
|
163
|
+
): readonly string[] => [
|
|
164
|
+
lintExceptionReason(reason),
|
|
165
|
+
...lint.errors.map((m) => ` ${lintFindingLine(m)}`),
|
|
166
|
+
];
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* ── WHY IT IS NOT A VIGILES PROGRAM LIKE ITS NEIGHBOURS (measured 2026-10-12, vigiles 38) ──────
|
|
29
29
|
* A shipped `.hook.mjs` may import nothing but `vigiles/hook` (`checkHookImports`), so it cannot call
|
|
30
30
|
* this package's function; its only way to a tool is `run()`, whose output reaches stderr and never
|
|
31
|
-
* the hook's answer (
|
|
31
|
+
* the hook's answer (measured 2026-09-12, vigiles 27); and a `provide()` command runs
|
|
32
32
|
* before the reaction without the event, so it cannot know which file is written. Each of the three
|
|
33
33
|
* would mean a second copy of the layout. So `paperlint hook paper-folder-layout` runs this module
|
|
34
34
|
* in-process (`runHook`, src/cli.ts), behind the same wiring command as the other hooks, which is
|
package/src/hooks-notice.test.ts
CHANGED
|
@@ -171,7 +171,7 @@ test("a wired hook on a paper file: missing hook → one notice, the same versio
|
|
|
171
171
|
});
|
|
172
172
|
|
|
173
173
|
test("the notice rides on what the hook said: a block stays a block, and the exit stays 0", async () => {
|
|
174
|
-
const dir = project("block", wiringWithout(["paper-
|
|
174
|
+
const dir = project("block", wiringWithout(["paper-skills-nudge"]), true);
|
|
175
175
|
const said = await hook(
|
|
176
176
|
"lint-edited",
|
|
177
177
|
dir,
|
|
@@ -186,7 +186,7 @@ test("the notice rides on what the hook said: a block stays a block, and the exi
|
|
|
186
186
|
assert.match(parsed.reason, /tex\/max-sentence-words/);
|
|
187
187
|
assert.match(
|
|
188
188
|
Notice.parse(parsed).hookSpecificOutput.additionalContext,
|
|
189
|
-
/paper-
|
|
189
|
+
/paper-skills-nudge/,
|
|
190
190
|
);
|
|
191
191
|
});
|
|
192
192
|
|
package/src/hooks-notice.ts
CHANGED
|
@@ -30,9 +30,18 @@ import type { Files } from "./ports/files.ts";
|
|
|
30
30
|
export const NOTICE_HOOKS: readonly string[] = [
|
|
31
31
|
"lint-edited",
|
|
32
32
|
"paper-skills-nudge",
|
|
33
|
-
"paper-status-gates",
|
|
34
33
|
];
|
|
35
34
|
|
|
35
|
+
/** What `paperlint hook [name]` says when it cannot run a hook: no name, or no such hook shipped. It names the remedy; the caller does not deny (#324). */
|
|
36
|
+
export const hookNotRunningText = (
|
|
37
|
+
name: string | undefined,
|
|
38
|
+
program: string,
|
|
39
|
+
version: string,
|
|
40
|
+
): string =>
|
|
41
|
+
name === undefined || name === ""
|
|
42
|
+
? "paperlint: `hook` needs a name, e.g. `paperlint hook paper-edit-guard`; no hook is running."
|
|
43
|
+
: `paperlint: unknown hook \`${name}\` — no such program at ${program}; it is NOT running (installed: paperlint ${version}). Run \`npm install\`, or remove \`paperlint hook ${name}\` from .claude/settings.json.`;
|
|
44
|
+
|
|
36
45
|
/** Where the version last told is kept, relative to the project root. */
|
|
37
46
|
export const NOTICE_STATE = join(
|
|
38
47
|
"node_modules",
|
|
@@ -65,9 +65,9 @@ check(
|
|
|
65
65
|
// ── the one source: plugin/hooks/hooks.json ─────────────────────────────────────────────
|
|
66
66
|
const wiring = shippedWiring();
|
|
67
67
|
check(
|
|
68
|
-
"the hook names are DERIVED from hooks.json —
|
|
68
|
+
"the hook names are DERIVED from hooks.json — five, in its order",
|
|
69
69
|
wiring.names.join() ===
|
|
70
|
-
"paper-edit-guard,submission-confirm,paper-folder-layout,paper-skills-nudge,
|
|
70
|
+
"paper-edit-guard,submission-confirm,paper-folder-layout,paper-skills-nudge,lint-edited",
|
|
71
71
|
);
|
|
72
72
|
// ── settings written by hand: shapes Claude Code would ignore are skipped, not crashed on ──
|
|
73
73
|
check(
|
|
@@ -140,8 +140,8 @@ try {
|
|
|
140
140
|
const cases: [string, { name: string; ours: boolean } | null][] = [
|
|
141
141
|
[ours, { name: "paper-edit-guard", ours: true }],
|
|
142
142
|
[
|
|
143
|
-
`node "$CLAUDE_PROJECT_DIR/${MANAGED_BY}" hook
|
|
144
|
-
{ name: "
|
|
143
|
+
`node "$CLAUDE_PROJECT_DIR/${MANAGED_BY}" hook lint-edited`,
|
|
144
|
+
{ name: "lint-edited", ours: true },
|
|
145
145
|
],
|
|
146
146
|
[
|
|
147
147
|
`node "$CLAUDE_PROJECT_DIR/node_modules/vigiles/dist/cli.js" hook-runtime run-program "$CLAUDE_PROJECT_DIR/node_modules/paperlint/hooks/paper-edit-guard.hook.mjs"`,
|
|
@@ -284,7 +284,7 @@ try {
|
|
|
284
284
|
"and names the hooks that are not wired in ANY form",
|
|
285
285
|
r.status === "foreign" &&
|
|
286
286
|
r.missing.join() ===
|
|
287
|
-
"submission-confirm,paper-folder-layout,paper-skills-nudge,
|
|
287
|
+
"submission-confirm,paper-folder-layout,paper-skills-nudge,lint-edited",
|
|
288
288
|
);
|
|
289
289
|
// The control: without the check, vigiles' merge WOULD add a second copy. This is the
|
|
290
290
|
// reason the check exists, measured rather than asserted.
|
|
@@ -320,13 +320,13 @@ try {
|
|
|
320
320
|
const wiredOnce = merge({}, wiring.compiled, MANAGED_BY);
|
|
321
321
|
check(
|
|
322
322
|
"wired once each → ✓ wired, with the fresh-clone consequence",
|
|
323
|
-
/✓ wired — paper-edit-guard, submission-confirm, paper-folder-layout, paper-skills-nudge,
|
|
323
|
+
/✓ wired — paper-edit-guard, submission-confirm, paper-folder-layout, paper-skills-nudge, lint-edited, once each/.test(
|
|
324
324
|
doc(wiredOnce),
|
|
325
325
|
) && /cannot run until `npm install`/.test(doc(wiredOnce)),
|
|
326
326
|
);
|
|
327
327
|
check(
|
|
328
328
|
"nothing wired → ⚠ not wired, with the remedy",
|
|
329
|
-
/⚠ not wired — none of the
|
|
329
|
+
/⚠ not wired — none of the 5 hooks/.test(doc({})),
|
|
330
330
|
);
|
|
331
331
|
const twice = PreToolUseSettings.parse(structuredClone(wiredOnce));
|
|
332
332
|
twice.hooks.PreToolUse[0]?.hooks.push({
|
|
@@ -354,7 +354,7 @@ try {
|
|
|
354
354
|
});
|
|
355
355
|
check(
|
|
356
356
|
"🔴 partly wired BY HAND → the remedy is NOT `npx paperlint init`, which would refuse to write",
|
|
357
|
-
/partly wired — missing: submission-confirm, paper-folder-layout, paper-skills-nudge,
|
|
357
|
+
/partly wired — missing: submission-confirm, paper-folder-layout, paper-skills-nudge, lint-edited/.test(
|
|
358
358
|
handPartial,
|
|
359
359
|
) && /writes nothing then/.test(handPartial),
|
|
360
360
|
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Result } from "../domain/result.ts";
|
|
2
|
+
import type { SubmissionLint } from "../domain/submission-lint.ts";
|
|
3
|
+
|
|
4
|
+
/** A completed paper lint, or the reason it could not make a decision. */
|
|
5
|
+
export type SubmissionLintResult = Result<SubmissionLint, string>;
|
|
6
|
+
|
|
7
|
+
export type SubmissionLinter = (
|
|
8
|
+
paperDir: string,
|
|
9
|
+
cwd: string,
|
|
10
|
+
) => Promise<SubmissionLintResult>;
|
package/src/structure.ts
CHANGED
|
@@ -142,9 +142,7 @@ export function formatStructure(findings: readonly StructureFinding[]): string {
|
|
|
142
142
|
* consumer to write a second parser — and the first one who did not write it would read "there
|
|
143
143
|
* are no structural findings" instead of "I do not parse them".
|
|
144
144
|
*/
|
|
145
|
-
export function asEslintResults(
|
|
146
|
-
findings: readonly StructureFinding[],
|
|
147
|
-
): unknown[] {
|
|
145
|
+
export function asEslintResults(findings: readonly StructureFinding[]) {
|
|
148
146
|
const byDir = new Map<string, string[]>();
|
|
149
147
|
for (const f of findings)
|
|
150
148
|
byDir.set(f.file, [...(byDir.get(f.file) ?? []), f.message]);
|
|
@@ -152,7 +150,7 @@ export function asEslintResults(
|
|
|
152
150
|
filePath,
|
|
153
151
|
messages: msgs.map((message: string) => ({
|
|
154
152
|
ruleId: "structure/required-file",
|
|
155
|
-
severity: 2,
|
|
153
|
+
severity: 2 as const,
|
|
156
154
|
message,
|
|
157
155
|
line: 0,
|
|
158
156
|
column: 0,
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `submission-confirm` hook over a lint exception: when the paper's lint cannot be run, the
|
|
3
|
+
* exception cannot be approved, and the refusal says why.
|
|
4
|
+
*/
|
|
5
|
+
import { expect, test } from "vitest";
|
|
6
|
+
import { leafCommandsNormalized as shellLeaves } from "vigiles/hook";
|
|
7
|
+
import { memoryFiles } from "./adapters/memory/index.ts";
|
|
8
|
+
import { err } from "./domain/result.ts";
|
|
9
|
+
import { submissionConfirm } from "./submission-confirm-hook.ts";
|
|
10
|
+
import { submissionSend, uploadSend } from "./cli.ts";
|
|
11
|
+
import { presetsDir } from "./package-dirs.ts";
|
|
12
|
+
import { PDF, facts, withPresets } from "../test/submission-fixtures.ts";
|
|
13
|
+
|
|
14
|
+
test("a lint exception is refused with the reason when the paper's lint could not be run", () => {
|
|
15
|
+
const command =
|
|
16
|
+
"npx paperlint submission update papers/p --submit --save --allow-lint-errors 'Known exception'";
|
|
17
|
+
const screen = submissionConfirm(
|
|
18
|
+
JSON.stringify({
|
|
19
|
+
tool_name: "Bash",
|
|
20
|
+
tool_input: { command },
|
|
21
|
+
cwd: "/w",
|
|
22
|
+
transcript_path: "/t/session.jsonl",
|
|
23
|
+
tool_use_id: "now",
|
|
24
|
+
}),
|
|
25
|
+
{
|
|
26
|
+
files: withPresets(
|
|
27
|
+
memoryFiles({
|
|
28
|
+
"/t/session.jsonl": "",
|
|
29
|
+
"/w/papers/p/paper.pdf": PDF,
|
|
30
|
+
"/w/papers/p/_build/paper.facts.json": facts(),
|
|
31
|
+
}),
|
|
32
|
+
),
|
|
33
|
+
venuesDir: presetsDir(),
|
|
34
|
+
portalHosts: () => [],
|
|
35
|
+
shellLeaves,
|
|
36
|
+
readSend: submissionSend,
|
|
37
|
+
readUpload: uploadSend,
|
|
38
|
+
lintPaper: () => err("paperlint lint did not produce a report"),
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
expect(screen?.hookSpecificOutput.permissionDecision).toBe("deny");
|
|
42
|
+
const shown = screen?.hookSpecificOutput.permissionDecisionReason ?? "";
|
|
43
|
+
expect(shown).toContain(
|
|
44
|
+
"Cannot approve a lint exception: paperlint lint did not produce a report",
|
|
45
|
+
);
|
|
46
|
+
expect(shown).not.toContain("Allow lint errors:");
|
|
47
|
+
});
|
|
@@ -7,6 +7,8 @@ import { expect, test } from "vitest";
|
|
|
7
7
|
import { memoryFiles } from "./adapters/memory/index.ts";
|
|
8
8
|
import type { AbsolutePath } from "./domain/paths.ts";
|
|
9
9
|
import { sha256Hex } from "./domain/sha256.ts";
|
|
10
|
+
import { ok } from "./domain/result.ts";
|
|
11
|
+
import { submissionLint } from "./domain/submission-lint.ts";
|
|
10
12
|
import type { Files } from "./ports/files.ts";
|
|
11
13
|
import { leafCommandsNormalized as shellLeaves } from "vigiles/hook";
|
|
12
14
|
import { submissionSend, uploadSend } from "./cli.ts";
|
|
@@ -44,6 +46,7 @@ const submissionConfirm = (
|
|
|
44
46
|
shellLeaves,
|
|
45
47
|
readSend: submissionSend,
|
|
46
48
|
readUpload: uploadSend,
|
|
49
|
+
lintPaper: () => ok(submissionLint([], null)),
|
|
47
50
|
...more,
|
|
48
51
|
});
|
|
49
52
|
|
|
@@ -156,11 +159,9 @@ const NOT_SENT = "Not run: this sends the paper to the venue's portal";
|
|
|
156
159
|
const HEAD = `${NOT_SENT}, and the person has not said yes to it since the last send.`;
|
|
157
160
|
/** What the agent is told to ask: the last lines of that refusal. */
|
|
158
161
|
const LAST = [
|
|
159
|
-
"Ask
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
"- the dry run's venue check, quoted word for word (its `venue rules at their default options` line and every error under it).",
|
|
163
|
-
'Options: "Yes, send it" and "No". One yes lets one send through: ask one question per send, each naming its own folder and sha256.',
|
|
162
|
+
"Ask with AskUserQuestion. Show the action, one lint summary line from the dry run, and the full paper folder, PDF and sha256 above.",
|
|
163
|
+
"For an exception, copy the Action, Lint exception, reason and blocking errors above. Mention stale or missing build facts.",
|
|
164
|
+
'Options: "Yes, proceed" and "No". One yes covers one command.',
|
|
164
165
|
].join("\n");
|
|
165
166
|
|
|
166
167
|
test("no yes: refused, telling the agent what to ask — the paper folder, the PDF and its sha256, the body pages, the venue check, yes or no", () => {
|
|
@@ -173,6 +174,7 @@ test("no yes: refused, telling the agent what to ask — the paper folder, the P
|
|
|
173
174
|
"paper folder: /w/papers/p",
|
|
174
175
|
`PDF: papers/p/paper.pdf, sha256 ${HEX.slice(0, 12)}`,
|
|
175
176
|
"body pages: 4 (up to the references on page 5)",
|
|
177
|
+
"Action: Mark submission ready for review",
|
|
176
178
|
LAST,
|
|
177
179
|
].join("\n"),
|
|
178
180
|
},
|
|
@@ -187,6 +189,7 @@ test("a stale build is said loudly; no facts and broken facts are said too", ()
|
|
|
187
189
|
`PDF: papers/p/paper.pdf, sha256 ${HEX.slice(0, 12)}`,
|
|
188
190
|
"!! THE LAST BUILD IS NOT OF THIS PDF — the check did not see it. Rebuild (`paperlint build`) and run the dry run again.",
|
|
189
191
|
"body pages: 4 (up to the references on page 5)",
|
|
192
|
+
"Action: Mark submission ready for review",
|
|
190
193
|
LAST,
|
|
191
194
|
].join("\n"),
|
|
192
195
|
);
|
|
@@ -221,6 +224,7 @@ test("a PDF that is not there: refused, whatever the transcript says — there i
|
|
|
221
224
|
"PDF: gone.pdf — NOT FOUND",
|
|
222
225
|
"!! THE LAST BUILD IS NOT OF THIS PDF — the check did not see it. Rebuild (`paperlint build`) and run the dry run again.",
|
|
223
226
|
"body pages: 4 (up to the references on page 5)",
|
|
227
|
+
"Action: Save changes to submission",
|
|
224
228
|
),
|
|
225
229
|
);
|
|
226
230
|
});
|
|
@@ -523,7 +527,11 @@ const asksAbout = (folder: string, sha: string) =>
|
|
|
523
527
|
const asks = (sha: string) => asksAbout("/w/papers/p", sha);
|
|
524
528
|
|
|
525
529
|
/** The hook's answer to SEND, over the paper with this transcript. */
|
|
526
|
-
const withTranscript = (
|
|
530
|
+
const withTranscript = (
|
|
531
|
+
lines: readonly string[],
|
|
532
|
+
command = SEND,
|
|
533
|
+
more: Partial<ConfirmDeps> = {},
|
|
534
|
+
) =>
|
|
527
535
|
submissionConfirm(
|
|
528
536
|
payload(command),
|
|
529
537
|
memoryFiles({
|
|
@@ -531,8 +539,67 @@ const withTranscript = (lines: readonly string[], command = SEND) =>
|
|
|
531
539
|
"/w/papers/p/paper.pdf": PDF,
|
|
532
540
|
"/w/papers/p/_build/paper.facts.json": facts(),
|
|
533
541
|
}),
|
|
542
|
+
more,
|
|
534
543
|
);
|
|
535
544
|
|
|
545
|
+
test("the lint exception requires its current reason, action and blocking findings in the question", () => {
|
|
546
|
+
const command = `${SEND} --allow-lint-errors 'Known exception'`;
|
|
547
|
+
const lintPaper = (message: string) => () =>
|
|
548
|
+
ok(
|
|
549
|
+
submissionLint(
|
|
550
|
+
[
|
|
551
|
+
{
|
|
552
|
+
file: "paper.tex",
|
|
553
|
+
ruleId: "repro/example",
|
|
554
|
+
severity: 2,
|
|
555
|
+
line: 4,
|
|
556
|
+
column: 2,
|
|
557
|
+
message,
|
|
558
|
+
},
|
|
559
|
+
],
|
|
560
|
+
null,
|
|
561
|
+
),
|
|
562
|
+
);
|
|
563
|
+
const check = { lintPaper: lintPaper("Missing result") };
|
|
564
|
+
const screen = withTranscript(
|
|
565
|
+
question("q1", asks(SHA), "Yes"),
|
|
566
|
+
command,
|
|
567
|
+
check,
|
|
568
|
+
);
|
|
569
|
+
expect(screen?.hookSpecificOutput.permissionDecision).toBe("deny");
|
|
570
|
+
const shown = screen?.hookSpecificOutput.permissionDecisionReason ?? "";
|
|
571
|
+
expect(shown).toContain('Allow lint errors: "Known exception"');
|
|
572
|
+
expect(shown).toContain(" paper.tex:4:2 repro/example — Missing result");
|
|
573
|
+
const exception = shown
|
|
574
|
+
.split("\n")
|
|
575
|
+
.filter((line) =>
|
|
576
|
+
["Action:", "Lint exception:", "Allow lint errors:", " paper.tex:"].some(
|
|
577
|
+
(start) => line.startsWith(start),
|
|
578
|
+
),
|
|
579
|
+
);
|
|
580
|
+
const approved = question(
|
|
581
|
+
"q2",
|
|
582
|
+
[asks(SHA), ...exception].join("\n"),
|
|
583
|
+
"Yes, proceed",
|
|
584
|
+
);
|
|
585
|
+
expect(withTranscript(approved, command, check)).toBeNull();
|
|
586
|
+
expect(
|
|
587
|
+
withTranscript(approved, command, {
|
|
588
|
+
lintPaper: lintPaper("Another result is missing"),
|
|
589
|
+
}),
|
|
590
|
+
).not.toBeNull();
|
|
591
|
+
expect(
|
|
592
|
+
withTranscript(
|
|
593
|
+
approved,
|
|
594
|
+
command.replace("Known exception", "New reason"),
|
|
595
|
+
check,
|
|
596
|
+
),
|
|
597
|
+
).not.toBeNull();
|
|
598
|
+
expect(
|
|
599
|
+
withTranscript(approved, command.replace(" --submit", ""), check),
|
|
600
|
+
).not.toBeNull();
|
|
601
|
+
});
|
|
602
|
+
|
|
536
603
|
test("a yes to a question naming the PDF's sha256: the send runs — the hook says nothing, so Claude Code's own permissions apply", () => {
|
|
537
604
|
expect(withTranscript(question("q1", asks(SHA), "Yes, send it"))).toBe(null);
|
|
538
605
|
// The answer is a yes by its first word, in any case, typed or chosen.
|