paperlint 20.1.0 → 20.1.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/.github/workflows/ci.yml +7 -0
- package/CLAUDE.md +2 -2
- package/CONTRIBUTING.md +2 -2
- package/{action.harness.mjs → action.test.mjs} +147 -138
- package/dist/domain/paper-layout.d.ts +18 -6
- package/dist/domain/paper-layout.d.ts.map +1 -1
- package/dist/domain/paper-layout.js +44 -38
- package/dist/domain/paper-layout.js.map +1 -1
- package/dist/eslint-rules/papers.js +1 -1
- package/dist/folder-layout-hook.js +1 -1
- package/dist/latex-log.d.ts +1 -1
- package/dist/latex-log.js +1 -1
- package/dist/latex-loop.d.ts +1 -1
- package/dist/latex-loop.js +1 -1
- package/dist/lib/paper-config.d.ts +3 -3
- package/dist/lib/paper-config.js +3 -3
- package/docs/e2e.md +9 -9
- package/docs/install.md +11 -11
- package/docs/rules/paper/allowed-files-only.md +31 -28
- package/docs/testing.md +3 -4
- package/eslint-rules/{install-path-literals.harness.mjs → install-path-literals.test.mjs} +14 -13
- package/eslint-rules/{latex-language.harness.mjs → latex-language-rules.test.mjs} +61 -51
- package/eslint-rules/{paper-stages.harness.mjs → paper-stages-rule.test.mjs} +66 -69
- package/eslint-rules/{papers.harness.mjs → papers.test.mjs} +41 -30
- package/eslint-rules/papers.ts +1 -1
- package/eslint-rules/{pdf-last-page-balance.harness.mjs → pdf-last-page-balance.test.mjs} +27 -15
- package/eslint-rules/{temp-root-realpath.harness.mjs → temp-root-realpath.test.mjs} +24 -24
- package/eslint-rules/{tex-build.harness.mjs → tex-build.test.mjs} +292 -271
- package/eslint.config.mjs +15 -2
- package/fixtures/pdf-facts/README.md +1 -1
- package/fixtures/render-paper/build-clean.sh +1 -1
- package/fixtures/toolchain-mirror/install-tl +1 -1
- package/lib/{agent-cli-version.harness.mjs → agent-cli-version.test.mjs} +17 -18
- package/lib/{paper-config.harness.mjs → paper-config.test.mjs} +21 -20
- package/lib/paper-config.ts +3 -3
- package/lib/{skill-trigger-cases.harness.mjs → skill-trigger-cases-carrier.test.mjs} +78 -115
- package/package.json +3 -3
- package/presets/acm-acmsmall.jsonc +1 -1
- package/scripts/check-workflow.test.ts +368 -0
- package/scripts/check.ts +2 -2
- package/scripts/eslint-file-length.mjs +9 -9
- package/scripts/eslint-report-guard.mjs +1 -1
- package/scripts/eslint-report-guard.test.mjs +1 -1
- package/scripts/harness-api.test.ts +7 -46
- package/scripts/{rules-see-files.harness.mjs → rules-see-files-rule.test.mjs} +10 -6
- package/scripts/rules-see-files.mjs +1 -1
- package/skills/paper-pipeline/{paper-pipeline.harness.mjs → paper-pipeline.test.mjs} +45 -46
- package/skills/paper-pipeline/scripts/{consumer.harness.mjs → consumer-paths.test.mjs} +66 -59
- package/skills/paper-pipeline/scripts/consumer.mjs +3 -3
- package/skills/paper-pipeline/scripts/{extract-ref-facts.harness.mjs → extract-ref-facts-cli.test.mjs} +29 -31
- package/skills/paper-pipeline/scripts/fixtures/real-bib/refs.bib +1 -1
- package/skills/paper-pipeline/scripts/{generated-code.harness.mjs → generated-code-fixtures.test.mjs} +39 -46
- package/skills/render-paper/{extract-pdf-facts.harness.ts → extract-pdf-facts.test.ts} +20 -13
- package/skills/render-paper/{render-paper.harness.mjs → render-paper.test.mjs} +41 -40
- package/src/adapters/pdfjs/fill.test.ts +1 -1
- package/src/{build-engine.harness.mjs → build-engine-prepare.test.mjs} +98 -81
- package/src/{build.harness.mjs → build-fake-tex.test.mjs} +61 -28
- package/src/{cli.harness.mjs → cli-e2e.test.mjs} +109 -103
- package/src/cli.test.ts +2 -2
- package/src/{doctor.harness.mjs → doctor-install.test.mjs} +28 -29
- package/src/domain/paper-layout.test.ts +89 -49
- package/src/domain/paper-layout.ts +61 -42
- package/src/{engine.harness.mjs → engine.test.mjs} +120 -106
- package/src/facts-file.test.ts +1 -1
- package/src/folder-layout-hook.test.ts +1 -1
- package/src/folder-layout-hook.ts +1 -1
- package/src/folder-layout-rule.test.ts +1 -1
- package/src/{hooks-settings.harness.ts → hooks-settings.test.ts} +161 -146
- package/src/latex-log.test.ts +395 -0
- package/src/latex-log.ts +1 -1
- package/src/latex-loop.test.ts +553 -0
- package/src/latex-loop.ts +1 -1
- package/src/layout-docs.test.ts +47 -0
- package/src/{link-skills.harness.ts → link-skills-fs.test.ts} +26 -26
- package/src/{new-paper.harness.mjs → new-paper-scaffold.test.mjs} +31 -19
- package/src/{pdf-facts.harness.ts → pdf-facts-tables.test.ts} +28 -22
- package/src/{pdf-geometry.harness.ts → pdf-geometry.test.ts} +93 -75
- package/src/{rules-config.harness.ts → rules-config.test.ts} +41 -31
- package/src/{structure.harness.ts → structure.test.ts} +12 -10
- package/src/{tex-requirements.harness.ts → tex-requirements-tables.test.ts} +106 -85
- package/src/{toolchain.harness.mjs → toolchain-mirror.test.mjs} +204 -186
- package/scripts/check.harness.ts +0 -343
- package/scripts/harness-api.frozen.json +0 -41
- package/src/latex-log.harness.ts +0 -382
- package/src/latex-loop.harness.ts +0 -515
|
@@ -18,7 +18,10 @@ import {
|
|
|
18
18
|
import { tmpdir } from "node:os";
|
|
19
19
|
import { dirname, join } from "node:path";
|
|
20
20
|
import { fileURLToPath } from "node:url";
|
|
21
|
-
import {
|
|
21
|
+
import { expect, it, vi } from "vitest";
|
|
22
|
+
|
|
23
|
+
// Several tests here run real ESLint, spawn processes or walk the repository.
|
|
24
|
+
vi.setConfig({ testTimeout: 120_000 });
|
|
22
25
|
|
|
23
26
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
24
27
|
const {
|
|
@@ -32,7 +35,11 @@ const {
|
|
|
32
35
|
supportedPlatform,
|
|
33
36
|
} = await import(join(HERE, "engine.ts"));
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
/** One soft assertion: a failed check does not stop the checks after it in the same test. */
|
|
39
|
+
const check = (label, cond, detail) =>
|
|
40
|
+
expect
|
|
41
|
+
.soft(cond, detail === undefined ? label : `${label}\n${detail}`)
|
|
42
|
+
.toBe(true);
|
|
36
43
|
|
|
37
44
|
// ── 1. resolveEngine ────────────────────────────────────────────────────────────────────
|
|
38
45
|
const tree = (label, missing = []) => ({ label, bin: `/${label}`, missing });
|
|
@@ -102,20 +109,22 @@ const ROWS = [
|
|
|
102
109
|
{ kind: "use-system", tree: COMPLETE_SYS },
|
|
103
110
|
],
|
|
104
111
|
];
|
|
105
|
-
|
|
106
|
-
const
|
|
112
|
+
it("1. resolveEngine", () => {
|
|
113
|
+
for (const [label, f, want] of ROWS) {
|
|
114
|
+
const got = resolveEngine(f);
|
|
115
|
+
check(
|
|
116
|
+
`resolveEngine: ${label}`,
|
|
117
|
+
JSON.stringify(got) === JSON.stringify(want),
|
|
118
|
+
JSON.stringify(got),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
107
121
|
check(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
122
|
+
"supportedPlatform: linux and darwin, not win32",
|
|
123
|
+
supportedPlatform("linux") &&
|
|
124
|
+
supportedPlatform("darwin") &&
|
|
125
|
+
!supportedPlatform("win32"),
|
|
111
126
|
);
|
|
112
|
-
}
|
|
113
|
-
check(
|
|
114
|
-
"supportedPlatform: linux and darwin, not win32",
|
|
115
|
-
supportedPlatform("linux") &&
|
|
116
|
-
supportedPlatform("darwin") &&
|
|
117
|
-
!supportedPlatform("win32"),
|
|
118
|
-
);
|
|
127
|
+
});
|
|
119
128
|
|
|
120
129
|
// ── 2. the fact readers ─────────────────────────────────────────────────────────────────
|
|
121
130
|
const PKGS = {
|
|
@@ -123,47 +132,50 @@ const PKGS = {
|
|
|
123
132
|
latex: ["latex.ltx", "article.cls"],
|
|
124
133
|
libertine: ["libertine.sty"],
|
|
125
134
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
missingTools
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
135
|
+
it("2. the fact readers: missingPackages, missingTools, whichOnPath", () => {
|
|
136
|
+
check(
|
|
137
|
+
"missingPackages: matched by FILE NAME of each printed path, sorted",
|
|
138
|
+
JSON.stringify(
|
|
139
|
+
missingPackages(PKGS, "/t/tex/latex/acmart/acmart.cls\n"),
|
|
140
|
+
) === '["latex","libertine"]',
|
|
141
|
+
);
|
|
142
|
+
// Guards: a package counts as present only when EVERY file that proves it resolves.
|
|
143
|
+
check(
|
|
144
|
+
"missingPackages: one proof of two missing is enough to count the package missing",
|
|
145
|
+
missingPackages(
|
|
146
|
+
{ latex: ["latex.ltx", "article.cls"] },
|
|
147
|
+
"/t/latex.ltx\n",
|
|
148
|
+
).includes("latex"),
|
|
149
|
+
);
|
|
150
|
+
check(
|
|
151
|
+
"missingPackages: all present → none",
|
|
152
|
+
missingPackages(
|
|
153
|
+
PKGS,
|
|
154
|
+
"/a/acmart.cls\n/b/latex.ltx\n/b/article.cls\n/c/libertine.sty\n",
|
|
155
|
+
).length === 0,
|
|
156
|
+
);
|
|
157
|
+
check(
|
|
158
|
+
"missingTools: by executable in the bin directory",
|
|
159
|
+
JSON.stringify(
|
|
160
|
+
missingTools(
|
|
161
|
+
{ texcount: ["texcount"], checkcites: ["checkcites"] },
|
|
162
|
+
"/bin",
|
|
163
|
+
(p) => p === "/bin/texcount",
|
|
164
|
+
),
|
|
165
|
+
) === '["checkcites"]',
|
|
166
|
+
);
|
|
167
|
+
check(
|
|
168
|
+
"whichOnPath: the first directory that has it; empty segments skipped",
|
|
169
|
+
whichOnPath("pdflatex", ":/a:/b:/c", (p) =>
|
|
170
|
+
["/b/pdflatex", "/c/pdflatex"].includes(p),
|
|
171
|
+
) === "/b",
|
|
172
|
+
);
|
|
173
|
+
check(
|
|
174
|
+
"whichOnPath: nowhere → null",
|
|
175
|
+
whichOnPath("pdflatex", "/a:/b", () => false) === null,
|
|
176
|
+
);
|
|
177
|
+
});
|
|
178
|
+
it("2. the fact readers: probeTree through a fake runner", () => {
|
|
167
179
|
const calls = [];
|
|
168
180
|
const run = (cmd, args) => {
|
|
169
181
|
calls.push([cmd, args]);
|
|
@@ -181,20 +193,22 @@ check(
|
|
|
181
193
|
"probeTree: kpsewhich's exit code is not the verdict — the printed paths are",
|
|
182
194
|
JSON.stringify(missing) === '["latex","libertine"]',
|
|
183
195
|
);
|
|
184
|
-
}
|
|
196
|
+
});
|
|
185
197
|
// Guards: "could not ask" must never read as "nothing missing" — a broken tree would be used.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
)
|
|
198
|
+
it("2. the fact readers: a kpsewhich that cannot start finds nothing", () => {
|
|
199
|
+
check(
|
|
200
|
+
"🔴 probeTree: a kpsewhich that cannot start finds NOTHING — never 'all present'",
|
|
201
|
+
JSON.stringify(
|
|
202
|
+
probeTree("/none", PKGS, () => ({ error: new Error("ENOENT") })),
|
|
203
|
+
) === '["acmart","latex","libertine"]',
|
|
204
|
+
);
|
|
205
|
+
});
|
|
192
206
|
|
|
193
207
|
// ── 3. "installed" means a regular file that can be run — on a REAL filesystem ─────────────
|
|
194
208
|
// 🔴 `existsSync` says yes to a directory and to a file without the execute bit; both then fail
|
|
195
209
|
// to start, while `paperlint toolchain --check` reported the tree verified. Checked on disk, not
|
|
196
210
|
// through an injected predicate, because the predicate is exactly what was wrong.
|
|
197
|
-
{
|
|
211
|
+
it('3. "installed" means a regular file that can be run — on a REAL filesystem', () => {
|
|
198
212
|
const bin = realpathSync(
|
|
199
213
|
mkdtempSync(join(tmpdir(), "paperlint-engine-bin-")),
|
|
200
214
|
);
|
|
@@ -246,7 +260,7 @@ check(
|
|
|
246
260
|
} finally {
|
|
247
261
|
rmSync(bin, { recursive: true, force: true });
|
|
248
262
|
}
|
|
249
|
-
}
|
|
263
|
+
});
|
|
250
264
|
|
|
251
265
|
// ── missingDependencies: what an install that "continued anyway" left out ──────────────────
|
|
252
266
|
// Real stdout of `tlmgr check depends` on a tree whose install-tl lost unicode-data to a mirror
|
|
@@ -256,7 +270,7 @@ const BROKEN_DEPENDS =
|
|
|
256
270
|
"\f DEPENDS WITHOUT PACKAGES:\n" +
|
|
257
271
|
"unicode-data in: collection-basic latex-bin luahbtex luatex\n" +
|
|
258
272
|
"\f PACKAGES NOT IN ANY COLLECTION: acmart booktabs caption\n";
|
|
259
|
-
{
|
|
273
|
+
it('missingDependencies: what an install that "continued anyway" left out', () => {
|
|
260
274
|
const calls = [];
|
|
261
275
|
const run = (cmd, args) => {
|
|
262
276
|
calls.push([cmd, args]);
|
|
@@ -280,45 +294,45 @@ const BROKEN_DEPENDS =
|
|
|
280
294
|
JSON.stringify(missing) === '["unicode-data"]',
|
|
281
295
|
JSON.stringify(missing),
|
|
282
296
|
);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
)
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
)
|
|
299
|
-
|
|
300
|
-
check(
|
|
301
|
-
"missingDependencies: a tlmgr that cannot start reports nothing (the tree is judged by probeTree alone)",
|
|
302
|
-
JSON.stringify(
|
|
303
|
-
missingDependencies("/tl/bin", () => ({ error: new Error("ENOENT") })),
|
|
304
|
-
) === "[]",
|
|
305
|
-
);
|
|
306
|
-
check(
|
|
307
|
-
"missingDependencies: a section that runs to the end of the output, with no header after it",
|
|
308
|
-
JSON.stringify(
|
|
309
|
-
missingDependencies("/tl/bin", () => ({
|
|
310
|
-
stdout:
|
|
311
|
-
"\f DEPENDS WITHOUT PACKAGES:\nunicode-data in: latex-bin\nhyphen-base in: x",
|
|
312
|
-
status: 2,
|
|
313
|
-
})),
|
|
314
|
-
) === '["hyphen-base","unicode-data"]',
|
|
315
|
-
);
|
|
316
|
-
check(
|
|
317
|
-
"a runner that returns no stdout at all: tlmgr lists nothing, kpsewhich finds nothing",
|
|
318
|
-
JSON.stringify(missingDependencies("/tl/bin", () => ({ status: 0 }))) ===
|
|
319
|
-
"[]" &&
|
|
320
|
-
JSON.stringify(probeTree("/tl/bin", PKGS, () => ({ status: 0 }))) ===
|
|
321
|
-
JSON.stringify(Object.keys(PKGS).sort()),
|
|
322
|
-
);
|
|
297
|
+
});
|
|
298
|
+
it("missingDependencies: the other cases", () => {
|
|
299
|
+
check(
|
|
300
|
+
"missingDependencies: packages outside any collection are not gaps",
|
|
301
|
+
JSON.stringify(
|
|
302
|
+
missingDependencies("/tl/bin", () => ({
|
|
303
|
+
stdout: "\f PACKAGES NOT IN ANY COLLECTION: acmart booktabs\n",
|
|
304
|
+
status: 2,
|
|
305
|
+
})),
|
|
306
|
+
) === "[]",
|
|
307
|
+
);
|
|
308
|
+
check(
|
|
309
|
+
"missingDependencies: a clean tree has none",
|
|
310
|
+
JSON.stringify(
|
|
311
|
+
missingDependencies("/tl/bin", () => ({ stdout: "", status: 0 })),
|
|
312
|
+
) === "[]",
|
|
313
|
+
);
|
|
323
314
|
|
|
324
|
-
|
|
315
|
+
check(
|
|
316
|
+
"missingDependencies: a tlmgr that cannot start reports nothing (the tree is judged by probeTree alone)",
|
|
317
|
+
JSON.stringify(
|
|
318
|
+
missingDependencies("/tl/bin", () => ({ error: new Error("ENOENT") })),
|
|
319
|
+
) === "[]",
|
|
320
|
+
);
|
|
321
|
+
check(
|
|
322
|
+
"missingDependencies: a section that runs to the end of the output, with no header after it",
|
|
323
|
+
JSON.stringify(
|
|
324
|
+
missingDependencies("/tl/bin", () => ({
|
|
325
|
+
stdout:
|
|
326
|
+
"\f DEPENDS WITHOUT PACKAGES:\nunicode-data in: latex-bin\nhyphen-base in: x",
|
|
327
|
+
status: 2,
|
|
328
|
+
})),
|
|
329
|
+
) === '["hyphen-base","unicode-data"]',
|
|
330
|
+
);
|
|
331
|
+
check(
|
|
332
|
+
"a runner that returns no stdout at all: tlmgr lists nothing, kpsewhich finds nothing",
|
|
333
|
+
JSON.stringify(missingDependencies("/tl/bin", () => ({ status: 0 }))) ===
|
|
334
|
+
"[]" &&
|
|
335
|
+
JSON.stringify(probeTree("/tl/bin", PKGS, () => ({ status: 0 }))) ===
|
|
336
|
+
JSON.stringify(Object.keys(PKGS).sort()),
|
|
337
|
+
);
|
|
338
|
+
});
|
package/src/facts-file.test.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* The document is assembled from hand-made measurements (pure), and `measurePaper` runs on
|
|
5
5
|
* in-memory files with a FAKE pdf.js reader and a FAKE measurer, so each outcome — read failed, not
|
|
6
6
|
* measured, measured — is chosen rather than hoped for. Reading real PDFs is
|
|
7
|
-
* `pdf-facts.
|
|
7
|
+
* `pdf-facts-tables.test.ts`'s job; banal as the measurer is `adapters/banal/index.test.ts`, and the
|
|
8
8
|
* real banal is `test/e2e/tex/banal.e2e.ts`.
|
|
9
9
|
*/
|
|
10
10
|
import assert from "node:assert/strict";
|
|
@@ -75,7 +75,7 @@ describe("paper-folder-layout hook — denies a new stray entry", () => {
|
|
|
75
75
|
},
|
|
76
76
|
});
|
|
77
77
|
expect(out?.hookSpecificOutput.permissionDecisionReason).toMatch(
|
|
78
|
-
/^`PLAN\.md`
|
|
78
|
+
/^`PLAN\.md` does not belong at a paper folder's root: move it to a section of PIPELINE-STATUS\.md[^\n]*$/u,
|
|
79
79
|
);
|
|
80
80
|
});
|
|
81
81
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* created, not at the next lint. PreToolUse on `Edit|Write|MultiEdit` (`plugin/hooks/hooks.json`):
|
|
4
4
|
* when the file about to be written does not exist yet and would add an entry the layout does not
|
|
5
5
|
* allow — at a paper folder's root, or at the top of its `repro/` — the call is denied, and the
|
|
6
|
-
* reason is the rule's own message: where the entry goes
|
|
6
|
+
* reason is the rule's own message: where the entry goes (for `repro/`, also its layout drawn). The agent writes it
|
|
7
7
|
* where it belongs instead, in the same turn.
|
|
8
8
|
*
|
|
9
9
|
* ── WHAT IT NEVER BLOCKS ─────────────────────────────────────────────────────────
|
|
@@ -75,7 +75,7 @@ describe("paper/allowed-files-only — reports", () => {
|
|
|
75
75
|
),
|
|
76
76
|
).toEqual([
|
|
77
77
|
expect.stringMatching(
|
|
78
|
-
/^`archive\/`
|
|
78
|
+
/^`archive\/` does not belong at a paper folder's root: move it to extra\//,
|
|
79
79
|
),
|
|
80
80
|
]);
|
|
81
81
|
});
|