paperlint 18.6.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.
- package/CLAUDE.md +2 -2
- package/CONTRIBUTING.md +5 -2
- package/README.md +6 -6
- package/dist/adapters/clack/index.d.ts +3 -0
- package/dist/adapters/clack/index.d.ts.map +1 -0
- package/dist/adapters/clack/index.js +3 -0
- package/dist/adapters/clack/index.js.map +1 -0
- package/dist/adapters/clack/prompts.io.d.ts +8 -0
- package/dist/adapters/clack/prompts.io.d.ts.map +1 -0
- package/dist/adapters/clack/prompts.io.js +20 -0
- package/dist/adapters/clack/prompts.io.js.map +1 -0
- package/dist/adapters/package-manager/index.d.ts +4 -0
- package/dist/adapters/package-manager/index.d.ts.map +1 -0
- package/dist/adapters/package-manager/index.js +4 -0
- package/dist/adapters/package-manager/index.js.map +1 -0
- package/dist/adapters/package-manager/install.io.d.ts +3 -0
- package/dist/adapters/package-manager/install.io.d.ts.map +1 -0
- package/dist/adapters/package-manager/install.io.js +23 -0
- package/dist/adapters/package-manager/install.io.js.map +1 -0
- package/dist/adapters/package-manager/manager.d.ts +13 -0
- package/dist/adapters/package-manager/manager.d.ts.map +1 -0
- package/dist/adapters/package-manager/manager.js +22 -0
- package/dist/adapters/package-manager/manager.js.map +1 -0
- package/dist/adapters/study-registry/index.d.ts +2 -2
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +42 -6
- package/dist/cli.js.map +1 -1
- package/dist/init.d.ts +38 -15
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +99 -39
- package/dist/init.js.map +1 -1
- package/dist/ports/project-install.d.ts +19 -0
- package/dist/ports/project-install.d.ts.map +1 -0
- package/dist/ports/project-install.js +2 -0
- package/dist/ports/project-install.js.map +1 -0
- package/dist/ports/prompts.d.ts +31 -0
- package/dist/ports/prompts.d.ts.map +1 -0
- package/dist/ports/prompts.js +2 -0
- package/dist/ports/prompts.js.map +1 -0
- package/dist/self-install.d.ts +65 -0
- package/dist/self-install.d.ts.map +1 -0
- package/dist/self-install.js +145 -0
- package/dist/self-install.js.map +1 -0
- package/dist/skill-chunks/chunk-65X5HVIJ.js +26462 -0
- package/dist/skill-chunks/chunk-6NU6CXUS.js +258 -0
- package/dist/skill-chunks/chunk-GRSXIWYF.js +352 -0
- package/dist/skill-chunks/chunk-IREAROCV.js +84 -0
- package/dist/skill-chunks/chunk-KWK6RT4T.js +24267 -0
- package/dist/skill-chunks/chunk-NPQVDEE4.js +19681 -0
- package/dist/skill-chunks/chunk-PJ4KNV4J.js +45 -0
- package/dist/skill-chunks/dist-UPCJMLBM.js +385 -0
- package/dist/skill-chunks/pdfjs-LUMEFOH2.js +39518 -0
- package/docs/e2e.md +10 -0
- package/docs/install.md +27 -16
- package/docs/prior-art/README.md +2 -0
- package/docs/prior-art/one-command-install.md +33 -0
- package/docs/prior-art/prompt-libraries.md +32 -0
- package/eslint.config.mjs +1 -0
- package/lib/skill-checks.mjs +17 -9
- package/lib/skill-checks.test.mjs +28 -15
- package/lib/skill-corpus.mjs +5 -2
- package/package.json +5 -3
- package/scripts/bundle-skills.test.ts +226 -0
- package/scripts/bundle-skills.ts +304 -0
- package/skills/argument-arc/SKILL.md +2 -2
- package/skills/argument-arc/SKILL.md.spec.ts +1 -1
- package/skills/argument-arc/scripts/headings.js +57 -13
- package/skills/build-label-page/scripts/label-page.js +2005 -93
- package/skills/cold-read-diff/scripts/cold-read.js +221 -14
- package/skills/label-agent-runs/scripts/labels.js +272 -348
- package/skills/paper-pipeline/scripts/extract-ref-facts.js +304 -0
- package/skills/pc-panel-review/scripts/prior-reviews.js +7244 -12
- package/skills/run-agent-grid/scripts/grid-guard.js +562 -627
- package/skills/verify-citations/SKILL.md +9 -9
- package/skills/verify-citations/SKILL.md.spec.ts +8 -8
- package/skills/verify-citations/scripts/bib-authors.js +228 -0
- package/skills/verify-citations/scripts/verify-cites.js +816 -0
- package/src/adapters/clack/index.ts +2 -0
- package/src/adapters/clack/prompts.io.ts +35 -0
- package/src/adapters/clack/prompts.test.ts +58 -0
- package/src/adapters/package-manager/index.test.ts +67 -0
- package/src/adapters/package-manager/index.ts +3 -0
- package/src/adapters/package-manager/install.io.ts +27 -0
- package/src/adapters/package-manager/manager.ts +33 -0
- package/src/cli.harness.mjs +41 -26
- package/src/cli.test.ts +93 -2
- package/src/cli.ts +75 -4
- package/src/init.test.ts +138 -27
- package/src/init.ts +128 -72
- package/src/ports/project-install.ts +18 -0
- package/src/ports/prompts.ts +27 -0
- package/src/self-install.test.ts +267 -0
- package/src/self-install.ts +224 -0
package/docs/e2e.md
CHANGED
|
@@ -72,6 +72,16 @@ that works under npm can be dead under pnpm with no error anywhere. The same run
|
|
|
72
72
|
binary **directly** rather than through `node <path>`: under npm `.bin` holds a symlink, under
|
|
73
73
|
pnpm a shell wrapper, and calling `node bin` measures the caller's habit instead of the package.
|
|
74
74
|
|
|
75
|
+
## `test/e2e/install/skill-scripts.e2e.ts` — the skill scripts, with no `node_modules`
|
|
76
|
+
|
|
77
|
+
A Claude Code plugin copy is the tarball unpacked without its dependencies. This run packs the
|
|
78
|
+
package, unpacks it into an empty directory, reads every `node <path>` command from the shipped
|
|
79
|
+
`SKILL.md` files and starts each with no arguments and empty stdin. Its whole result (exit code,
|
|
80
|
+
stdout, stderr) must equal the same script's source run in this checkout, where its dependencies
|
|
81
|
+
resolve, and each command must be spelled `node ${CLAUDE_SKILL_DIR}/…`. Before the bundle step
|
|
82
|
+
(`scripts/bundle-skills.ts`, part of `npm run build`) all nine died with `ERR_MODULE_NOT_FOUND`.
|
|
83
|
+
It proves each script reaches its own argument handling; it does not run a real paper through them.
|
|
84
|
+
|
|
75
85
|
## `test/e2e/tex/build.e2e.ts` — a real `pdflatex`
|
|
76
86
|
|
|
77
87
|
It copies `fixtures/build-e2e/` — nine papers, none with a build script paperlint would run — into
|
package/docs/install.md
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
# Installation
|
|
2
2
|
|
|
3
|
-
This page covers what `
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
This page covers what `npx paperlint init` sets up, exactly what it writes, which package managers
|
|
4
|
+
work, what the install weighs, and what to do when something is off. The README has the short
|
|
5
|
+
version.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npm i -D paperlint
|
|
11
10
|
npx paperlint init
|
|
12
11
|
```
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
One command. When it runs from npx's cache rather than from your project, `init` first adds
|
|
14
|
+
paperlint to the project's devDependencies at its own version, saved exact
|
|
15
|
+
(`npm install --save-dev --save-exact paperlint@<version>`), so the command and the package cannot
|
|
16
|
+
drift. The package manager is the one your lockfile names (`package-lock.json`, `pnpm-lock.yaml`,
|
|
17
|
+
`yarn.lock`, `bun.lock`), npm when there is none. A project without a `package.json` gets a minimal
|
|
18
|
+
one (`private`, named after the folder), and `init` says so.
|
|
19
|
+
|
|
20
|
+
At a terminal it asks first, with Yes preselected; No stops `init` and prints the command to run
|
|
21
|
+
by hand. An agent, CI or `--yes` gets it added without a question, and the command is printed
|
|
22
|
+
before it runs. Already in the project: nothing is added. At another version than the `init` you
|
|
23
|
+
ran: `init` says which, keeps the installed one, and prints the command that would change it.
|
|
24
|
+
`npm i -D paperlint` followed by `npx paperlint init` still works the same way.
|
|
16
25
|
|
|
17
26
|
The npm package carries everything: the `paperlint` command, the ESLint rules, the Claude Code skills
|
|
18
27
|
and hooks, and the scripts the skills run. External programs are separate:
|
|
@@ -28,6 +37,7 @@ and hooks, and the scripts the skills run. External programs are separate:
|
|
|
28
37
|
|
|
29
38
|
In order:
|
|
30
39
|
|
|
40
|
+
0. **Adds paperlint to the project**, unless it is already there (above).
|
|
31
41
|
1. **Finds the papers directory**, or asks for it when several directories look like one.
|
|
32
42
|
2. **Declares it**, in a root `paperlint.json`, only when it is not the default `papers`. A project
|
|
33
43
|
on the defaults gets no config file at all.
|
|
@@ -42,20 +52,21 @@ In order:
|
|
|
42
52
|
9. **Runs `paperlint doctor`** and exits with its verdict.
|
|
43
53
|
|
|
44
54
|
It asks only what it cannot guess or what costs something. A human at a terminal is asked; an
|
|
45
|
-
agent, CI or `--yes` takes the defaults, and `init` prints which default it took.
|
|
46
|
-
|
|
55
|
+
agent, CI or `--yes` takes the defaults, and `init` prints which default it took. A question whose
|
|
56
|
+
input ends (Ctrl+D) takes the default; Ctrl+C stops `init` at that question, writes nothing after
|
|
57
|
+
it, and exits 130.
|
|
47
58
|
|
|
48
59
|
## What `paperlint init` writes
|
|
49
60
|
|
|
50
|
-
| what | where | when
|
|
51
|
-
| -------------------------------------------------------------------- | ----------------------- |
|
|
52
|
-
| `{ "papersDir": … }` naming your papers directory | `paperlint.json` | only when it is not the default `papers`
|
|
53
|
-
| the six hook commands, merged in beside your own entries | `.claude/settings.json` | by default. A human at a terminal is asked
|
|
54
|
-
| a GitHub Actions workflow: `npm ci`, then `./node_modules/paperlint` | `.github/workflows/` | only if you say yes; it asks once, and only when a human is at a terminal (stdin and stdout, no `CI`, no `--yes`)
|
|
55
|
-
| a first paper, via `paperlint new`, with its layout's folders | `<papers>/<name>/` | only when the papers directory holds none: asked of a human at a terminal, otherwise only with `--paper <name>`
|
|
56
|
-
| one relative symlink per shipped skill, into the installed package | `.claude/skills/<name>` | always — except where that name is already taken (a directory, a file, a link elsewhere): that entry is left as it is and named in the report
|
|
61
|
+
| what | where | when |
|
|
62
|
+
| -------------------------------------------------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
63
|
+
| `{ "papersDir": … }` naming your papers directory | `paperlint.json` | only when it is not the default `papers` |
|
|
64
|
+
| the six hook commands, merged in beside your own entries | `.claude/settings.json` | by default. A human at a terminal is asked (Yes preselected); an agent, CI or `--yes` gets YES; `--no-hooks` skips. Hand-wired under another spelling: nothing written, so nothing runs twice |
|
|
65
|
+
| a GitHub Actions workflow: `npm ci`, then `./node_modules/paperlint` | `.github/workflows/` | only if you say yes; it asks once, and only when a human is at a terminal (stdin and stdout, no `CI`, no `--yes`) |
|
|
66
|
+
| a first paper, via `paperlint new`, with its layout's folders | `<papers>/<name>/` | only when the papers directory holds none: asked of a human at a terminal, otherwise only with `--paper <name>` |
|
|
67
|
+
| one relative symlink per shipped skill, into the installed package | `.claude/skills/<name>` | always — except where that name is already taken (a directory, a file, a link elsewhere): that entry is left as it is and named in the report |
|
|
57
68
|
|
|
58
|
-
|
|
69
|
+
Besides paperlint itself (step 0), it installs no software you did not say yes to, and touches nothing else. Commit `.claude/settings.json` so every clone
|
|
59
70
|
gets the hooks; the hook commands run files inside `node_modules`, so a fresh clone needs
|
|
60
71
|
`npm install` first.
|
|
61
72
|
|
package/docs/prior-art/README.md
CHANGED
|
@@ -27,6 +27,8 @@ be citable for each one separately.
|
|
|
27
27
|
| [`paper-folder-scaffolding.md`](paper-folder-scaffolding.md) | who creates a paper folder, and who wires the hooks — a command or a human? | ship the template as a FILE and scaffold from it (`rpp new`); `init` writes the hooks into `.claude/settings.json` instead of printing `/plugin` lines |
|
|
28
28
|
| [`citation-checkers.md`](citation-checkers.md) | could the reference check depend on an existing package, and how could it be faster? | no dependable package exists (all Python, mostly prototypes); keep the in-repo checker, and the speedups are batch endpoints (Semantic Scholar, OpenAlex) and a committed cache of responses |
|
|
29
29
|
| [`edit-time-lint.md`](edit-time-lint.md) | how do tools report only the findings a change introduced? | each compares against a recorded before; none names the new finding for one edit, so the `lint-edited` hook keeps a per-finding snapshot and falls back to reviewdog's `added` lines |
|
|
30
|
+
| [`one-command-install.md`](one-command-install.md) | how does an initializer add its own package to the project? | as `npm init @eslint/config` does, but pinned to the running version, the manager read from the lockfile, a missing `package.json` created, and no question without a terminal |
|
|
31
|
+
| [`prompt-libraries.md`](prompt-libraries.md) | which library draws `paperlint init`'s questions? | `@clack/prompts`, pinned: the smallest maintained one with confirm, select, text and a cancel; Ctrl+C now stops init (exit 130) instead of taking the default |
|
|
30
32
|
| [`hotcrp-option-types.md`](hotcrp-option-types.md) | which kinds of field can a HotCRP submission form hold, and which can `submission_fields` carry? | HotCRP's 15 option types read from its source (commit `0c03b263e3b4`); every one the API can set has a kind except file uploads (declared, never sent), author certification and section breaks |
|
|
31
33
|
|
|
32
34
|
## Tools examined, and for what
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# How an initializer adds its own package to the project
|
|
2
|
+
|
|
3
|
+
`npx paperlint init` adds paperlint to the project it runs in, so the install is one command. The
|
|
4
|
+
model is ESLint's initializer, `npm init @eslint/config`.
|
|
5
|
+
|
|
6
|
+
## What `@eslint/create-config` does
|
|
7
|
+
|
|
8
|
+
Read from the published package, `@eslint/create-config` 3.2.0 (`npm pack @eslint/create-config`,
|
|
9
|
+
2026-11-22; source at https://github.com/eslint/create-config):
|
|
10
|
+
|
|
11
|
+
| step | what it does | where |
|
|
12
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------- |
|
|
13
|
+
| no `package.json` | stops: "A package.json file is necessary to initialize ESLint. Run `npm init` to create a package.json file and try again." | `bin/create-config.js` |
|
|
14
|
+
| what it installs | `eslint` and the plugins the answers chose, unpinned, into devDependencies | `lib/config-generator.js`, `result.devDependencies` |
|
|
15
|
+
| asking | a toggle "Would you like to install them now?" with Yes preselected (`initial: 1`), then "Which package manager do you want to use?" npm/yarn/pnpm/bun | `lib/questions.js`, `installationQuestions` |
|
|
16
|
+
| the package manager | asked, never read from a lockfile; default npm | the same |
|
|
17
|
+
| the command | `spawn.sync(<manager>, [yarn ? "add" : "install", "-D", ...packages])` | `lib/utils/npm-utils.js`, `installSyncSaveDev` |
|
|
18
|
+
| No | writes the config anyway and warns "You will need to install the dependencies yourself." | `lib/config-generator.js`, `output()` |
|
|
19
|
+
| Ctrl+C | "Operation canceled", exit 1 | `bin/create-config.js` |
|
|
20
|
+
| without a terminal | no flag skips the questions | |
|
|
21
|
+
|
|
22
|
+
## What paperlint does differently, and why
|
|
23
|
+
|
|
24
|
+
- **The version is pinned to the running one** (`paperlint@<version>`, saved exact). The command
|
|
25
|
+
that ran and the package it installed cannot drift; ESLint installs whatever is latest.
|
|
26
|
+
- **The package manager comes from the lockfile** (`package-lock.json`, `pnpm-lock.yaml`,
|
|
27
|
+
`yarn.lock`, `bun.lock` or `bun.lockb`), npm when there is none: the project already chose one.
|
|
28
|
+
- **A missing `package.json` is created** (`private: true`, the folder's name), and said in one
|
|
29
|
+
line: the paper repositories this is for are often not JavaScript projects.
|
|
30
|
+
- **Without a terminal it installs without asking**, printing the command: that is what running
|
|
31
|
+
`init` asked for. ESLint has no such path.
|
|
32
|
+
- **Already installed at another version**: said, and kept. Nothing is upgraded or downgraded
|
|
33
|
+
silently.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Which library draws `paperlint init`'s questions
|
|
2
|
+
|
|
3
|
+
`paperlint init` asked its questions through `node:readline` until 2026-11-22, typed as
|
|
4
|
+
`[Y/n]` text. They now go through one port (`src/ports/prompts.ts`: a yes/no, a choice, a line of
|
|
5
|
+
text), drawn by `@clack/prompts` in `src/adapters/clack/`.
|
|
6
|
+
|
|
7
|
+
## The candidates, measured 2026-11-22
|
|
8
|
+
|
|
9
|
+
Each package installed alone into an empty directory with npm; downloads from api.npmjs.org for the
|
|
10
|
+
week 2026-11-14 to 2026-11-20.
|
|
11
|
+
|
|
12
|
+
| package | version | packages installed | on disk | downloads a week | last release |
|
|
13
|
+
| ------------------- | ------- | ------------------ | ------- | ---------------- | ------------ |
|
|
14
|
+
| `@clack/prompts` | 1.9.0 | 6 | 336 KB | 48.6 M | 2026-11-09 |
|
|
15
|
+
| `@inquirer/prompts` | 8.8.0 | 27 | 1900 KB | 66.4 M | |
|
|
16
|
+
| `@inquirer/confirm` | 6.4.0 | 13 | 672 KB | | |
|
|
17
|
+
| `prompts` | 2.4.2 | 3 | 476 KB | 98.2 M | 2023-10 |
|
|
18
|
+
| `enquirer` | 2.4.1 | 4 | 424 KB | 50.9 M | 2023-07 |
|
|
19
|
+
|
|
20
|
+
**Chosen: `@clack/prompts`**, pinned. The smallest on disk of the maintained ones (`prompts` and
|
|
21
|
+
`enquirer` have not released since 2023), and it has the three questions init asks
|
|
22
|
+
(`confirm`, `select`, `text`) plus a cancel value (`isCancel`).
|
|
23
|
+
|
|
24
|
+
## Two behaviours, measured on a pseudo-terminal
|
|
25
|
+
|
|
26
|
+
- **Ctrl+C.** Under readline, Ctrl+C at a question rejected it, the rejection was read as "no
|
|
27
|
+
answer", and the question's default was taken: a Ctrl+C at the hooks question wired the hooks,
|
|
28
|
+
and the run went on and exited 0. Under clack it is a cancel: init prints one line, writes nothing
|
|
29
|
+
after that question, and exits 130 (`CANCELLED_CODE` in `src/init.ts`).
|
|
30
|
+
- **Width.** Clack redraws a question by moving the cursor up as many lines as it drew. On a
|
|
31
|
+
pseudo-terminal with no size set it counted every character as a line (`ESC[2280A`), so a test
|
|
32
|
+
that drives it on a pseudo-terminal sets the window size first.
|
package/eslint.config.mjs
CHANGED
|
@@ -252,6 +252,7 @@ export const IO_MODULES = [
|
|
|
252
252
|
* (`IO_MODULES`).
|
|
253
253
|
*/
|
|
254
254
|
export const TOOL_PACKAGES = [
|
|
255
|
+
"@clack/prompts", // the terminal questions of `paperlint init`
|
|
255
256
|
"@eslint/markdown", // ESLint's Markdown language
|
|
256
257
|
"@eslint/plugin-kit",
|
|
257
258
|
"@retorquere/bibtex-parser", // BibTeX
|
package/lib/skill-checks.mjs
CHANGED
|
@@ -35,6 +35,8 @@ import {
|
|
|
35
35
|
} from "../skills/paper-pipeline/scripts/consumer.mjs";
|
|
36
36
|
|
|
37
37
|
const PIPELINE = pipelineScripts(scriptsRoot({ env: {}, cwd: ROOT }));
|
|
38
|
+
/** How a SKILL.md names its own directory in a command: Claude Code substitutes it wherever the skill is. */
|
|
39
|
+
const SKILL_DIR_VAR = "${CLAUDE_SKILL_DIR}/";
|
|
38
40
|
|
|
39
41
|
/** How a skill names a file of the package's presets directory. */
|
|
40
42
|
const PRESETS_PREFIX = "presets/";
|
|
@@ -113,18 +115,21 @@ export async function checkSkill(name) {
|
|
|
113
115
|
// ═══════════════════════════════════════════════════════════════════════════════════════════════
|
|
114
116
|
// 7. EVERY script path the skill instructs resolves.
|
|
115
117
|
//
|
|
116
|
-
// Scoped to paths that are unambiguously resolvable:
|
|
117
|
-
//
|
|
118
|
+
// Scoped to paths that are unambiguously resolvable: `${CLAUDE_SKILL_DIR}/…` and `scripts/…` are
|
|
119
|
+
// skill-relative, `.claude/…` is repo-root-relative. A `.js` a skill runs is a build output
|
|
120
|
+
// (`npm run build`), so this checks the checkout as built. Paths
|
|
118
121
|
// like `repro/build-submission.sh` are relative to a PAPER directory that does not exist at test
|
|
119
122
|
// time, so they are excluded BY NAME rather than by a guess that would fire on correct text.
|
|
120
123
|
// ═══════════════════════════════════════════════════════════════════════════════════════════════
|
|
121
124
|
for (const s of skills) {
|
|
122
125
|
for (const c of commands(s.src)) {
|
|
123
|
-
const abs = c.script.startsWith(
|
|
124
|
-
? join(
|
|
125
|
-
: c.script.startsWith("
|
|
126
|
-
? join(
|
|
127
|
-
:
|
|
126
|
+
const abs = c.script.startsWith(SKILL_DIR_VAR)
|
|
127
|
+
? join(SKILLS_DIR, s.name, c.script.slice(SKILL_DIR_VAR.length))
|
|
128
|
+
: c.script.startsWith(".claude/")
|
|
129
|
+
? join(ROOT, c.script)
|
|
130
|
+
: c.script.startsWith("scripts/")
|
|
131
|
+
? join(SKILLS_DIR, s.name, c.script)
|
|
132
|
+
: null;
|
|
128
133
|
if (!abs) continue;
|
|
129
134
|
soft(() =>
|
|
130
135
|
assert.ok(
|
|
@@ -144,8 +149,11 @@ export async function checkSkill(name) {
|
|
|
144
149
|
// ═══════════════════════════════════════════════════════════════════════════════════════════════
|
|
145
150
|
for (const s of skills) {
|
|
146
151
|
for (const c of commands(s.src)) {
|
|
147
|
-
// The pipeline's own scripts; any other command is the consumer's business.
|
|
148
|
-
|
|
152
|
+
// The pipeline's own scripts, by either spelling; any other command is the consumer's business.
|
|
153
|
+
const own =
|
|
154
|
+
c.script.startsWith(PIPELINE.prefix) ||
|
|
155
|
+
c.script.startsWith(SKILL_DIR_VAR);
|
|
156
|
+
if (!own) continue;
|
|
149
157
|
soft(() =>
|
|
150
158
|
assert.ok(
|
|
151
159
|
s.tools.some((t) => permits(t, c.cmd)),
|
|
@@ -186,7 +186,7 @@ test("checkSkill reports EVERY finding at once: a renamed skill with no descript
|
|
|
186
186
|
|
|
187
187
|
test("checkSkill refuses an instructed script that does not exist", async () => {
|
|
188
188
|
const lines = await brokenBy("verify-citations", (s) =>
|
|
189
|
-
s.replaceAll("scripts/extract-ref-facts.
|
|
189
|
+
s.replaceAll("scripts/extract-ref-facts.js", "scripts/missing.js"),
|
|
190
190
|
);
|
|
191
191
|
assert.equal(
|
|
192
192
|
lines?.[0],
|
|
@@ -194,7 +194,22 @@ test("checkSkill refuses an instructed script that does not exist", async () =>
|
|
|
194
194
|
);
|
|
195
195
|
assert.match(
|
|
196
196
|
lines?.[1] ?? "",
|
|
197
|
-
/instructs `node .*missing\.
|
|
197
|
+
/instructs `node .*missing\.js.*` but .*missing\.js does not exist/,
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("checkSkill resolves a bare scripts/ path from the skill's own directory", async () => {
|
|
202
|
+
const spelled = (path) => (s) =>
|
|
203
|
+
s.replaceAll("${CLAUDE_SKILL_DIR}/scripts/bib-authors.js", path);
|
|
204
|
+
// Guards: a bare path to a script the skill has is accepted.
|
|
205
|
+
assert.equal(
|
|
206
|
+
await brokenBy("verify-citations", spelled("scripts/bib-authors.mjs")),
|
|
207
|
+
null,
|
|
208
|
+
);
|
|
209
|
+
// Guards: a bare path to a script it lacks is refused, once per line that names it.
|
|
210
|
+
assert.deepEqual(
|
|
211
|
+
(await brokenBy("verify-citations", spelled("scripts/missing.js")))?.[0],
|
|
212
|
+
'2 assertion(s) failed for skill "verify-citations":',
|
|
198
213
|
);
|
|
199
214
|
});
|
|
200
215
|
|
|
@@ -209,41 +224,39 @@ test("checkSkill refuses a pipeline script the skill's allowed-tools do not perm
|
|
|
209
224
|
.join(", ")}]`,
|
|
210
225
|
),
|
|
211
226
|
);
|
|
227
|
+
// Guards: each of the seven `node ${CLAUDE_SKILL_DIR}/…` lines is named, the first one first.
|
|
212
228
|
assert.equal(
|
|
213
229
|
lines?.[0],
|
|
214
|
-
'
|
|
230
|
+
'7 assertion(s) failed for skill "verify-citations":',
|
|
215
231
|
);
|
|
216
232
|
assert.match(
|
|
217
233
|
lines?.[1] ?? "",
|
|
218
|
-
/
|
|
234
|
+
/verify-cites\.js.* permit no such Bash command/,
|
|
219
235
|
);
|
|
220
236
|
});
|
|
221
237
|
|
|
222
|
-
test("a Bash entry
|
|
223
|
-
const narrowTo = (
|
|
238
|
+
test("a Bash entry that covers the instructed scripts permits them, and one narrowed to another does not", async () => {
|
|
239
|
+
const narrowTo = (pattern) => (s) =>
|
|
224
240
|
s.replace(
|
|
225
241
|
/^allowed-tools: \[(.*)\]$/m,
|
|
226
242
|
(_, list) =>
|
|
227
243
|
`allowed-tools: [${list
|
|
228
244
|
.split(", ")
|
|
229
245
|
.map((t) =>
|
|
230
|
-
t === "Bash"
|
|
231
|
-
? `"Bash(node .claude/skills/paper-pipeline/scripts/${script}:*)"`
|
|
232
|
-
: t,
|
|
246
|
+
t === "Bash" ? `"Bash(node \${CLAUDE_SKILL_DIR}/${pattern}:*)"` : t,
|
|
233
247
|
)
|
|
234
248
|
.join(", ")}]`,
|
|
235
249
|
);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
null,
|
|
239
|
-
);
|
|
250
|
+
// Guards: an entry that covers the skill's own scripts permits all seven commands.
|
|
251
|
+
assert.equal(await brokenBy("verify-citations", narrowTo("*")), null);
|
|
240
252
|
const lines = await brokenBy(
|
|
241
253
|
"verify-citations",
|
|
242
|
-
narrowTo("
|
|
254
|
+
narrowTo("../paper-pipeline/scripts/extract-ref-facts.js"),
|
|
243
255
|
);
|
|
256
|
+
// Guards: narrowed to one script, the other five commands (verify-cites.js, bib-authors.js) are named.
|
|
244
257
|
assert.equal(
|
|
245
258
|
lines?.[0],
|
|
246
|
-
'
|
|
259
|
+
'5 assertion(s) failed for skill "verify-citations":',
|
|
247
260
|
);
|
|
248
261
|
assert.match(lines?.[1] ?? "", /permit no such Bash command/);
|
|
249
262
|
});
|
package/lib/skill-corpus.mjs
CHANGED
|
@@ -129,11 +129,14 @@ export function permits(entry, cmd) {
|
|
|
129
129
|
return rx.test(cmd);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Every `node|bash|python3 <script>` line the SKILL.md instructs, with its full command text. The
|
|
134
|
+
* script may start with `${CLAUDE_SKILL_DIR}/`, the skill's own directory wherever it is installed.
|
|
135
|
+
*/
|
|
133
136
|
export function commands(src) {
|
|
134
137
|
return [
|
|
135
138
|
...src.matchAll(
|
|
136
|
-
/^\s*(node|bash|python3?) +([A-Za-z0-9_./@-]+\.(?:mjs|js|sh|py))(.*)$/gm,
|
|
139
|
+
/^\s*(node|bash|python3?) +((?:\$\{CLAUDE_SKILL_DIR\}\/)?[A-Za-z0-9_./@-]+\.(?:mjs|js|sh|py))(.*)$/gm,
|
|
137
140
|
),
|
|
138
141
|
].map((m) => ({
|
|
139
142
|
runner: m[1],
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paperlint",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.7.0",
|
|
4
4
|
"description": "A linter for scientific papers written in LaTeX: catches mistakes before you submit to a conference or journal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsc -b",
|
|
9
|
-
"prepare": "tsc -b",
|
|
8
|
+
"build": "tsc -b && node scripts/bundle-skills.ts",
|
|
9
|
+
"prepare": "tsc -b && node scripts/bundle-skills.ts",
|
|
10
10
|
"test": "node scripts/test.ts",
|
|
11
11
|
"test:e2e": "vitest run --project 'e2e-*'",
|
|
12
12
|
"test:e2e:install": "vitest run --project e2e-install",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"site:build": "npm ci --prefix site && npm run lint --prefix site && npm run typecheck --prefix site && npm run test --prefix site && npm run build --prefix site"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"@clack/prompts": "1.9.0",
|
|
26
27
|
"@eslint/markdown": "^8.0.3",
|
|
27
28
|
"@eslint/plugin-kit": "^0.7.2",
|
|
28
29
|
"@retorquere/bibtex-parser": "^10.0.1",
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"c8": "^12.0.0",
|
|
57
58
|
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
58
59
|
"dependency-graph": "^1.0.0",
|
|
60
|
+
"esbuild": "0.28.2",
|
|
59
61
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
60
62
|
"eslint-plugin-boundaries": "^7.2.0",
|
|
61
63
|
"eslint-plugin-functional": "^10.0.1",
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bundle step (`scripts/bundle-skills.ts`) on fixture trees of its own: it writes every bundle
|
|
3
|
+
* and nothing else, the bundles keep each module's own `import.meta`, and it refuses before writing
|
|
4
|
+
* anything when a run would overwrite a tracked file or break an entry. Then the real step on this
|
|
5
|
+
* checkout, as `npm run build` runs it.
|
|
6
|
+
*/
|
|
7
|
+
import { execFileSync } from "node:child_process";
|
|
8
|
+
import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { dirname, join, relative } from "node:path";
|
|
10
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
11
|
+
import { describe, expect, it } from "vitest";
|
|
12
|
+
import { runNode, useTempDir, writeTree } from "../test/support.ts";
|
|
13
|
+
import {
|
|
14
|
+
bundleSkills,
|
|
15
|
+
CHUNK_DIR,
|
|
16
|
+
gitTracked,
|
|
17
|
+
SKILL_ENTRIES,
|
|
18
|
+
type BundlePlan,
|
|
19
|
+
} from "./bundle-skills.ts";
|
|
20
|
+
|
|
21
|
+
const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
22
|
+
|
|
23
|
+
/** Every file under `root`, relative, with its contents. */
|
|
24
|
+
function snapshot(root: string): Readonly<Record<string, string>> {
|
|
25
|
+
const walk = (dir: string): readonly string[] =>
|
|
26
|
+
readdirSync(dir).flatMap((name) => {
|
|
27
|
+
const p = join(dir, name);
|
|
28
|
+
return statSync(p).isDirectory() ? walk(p) : [p];
|
|
29
|
+
});
|
|
30
|
+
return Object.fromEntries(
|
|
31
|
+
walk(root).map((p) => [relative(root, p), readFileSync(p, "utf8")]),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** What changed between two snapshots. */
|
|
36
|
+
function delta(
|
|
37
|
+
before: Readonly<Record<string, string>>,
|
|
38
|
+
after: Readonly<Record<string, string>>,
|
|
39
|
+
): { added: string[]; removed: string[]; changed: string[] } {
|
|
40
|
+
const keys = (o: object): string[] => Object.keys(o).sort();
|
|
41
|
+
return {
|
|
42
|
+
added: keys(after).filter((k) => !(k in before)),
|
|
43
|
+
removed: keys(before).filter((k) => !(k in after)),
|
|
44
|
+
changed: keys(after).filter((k) => k in before && before[k] !== after[k]),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A module that reports where it thinks it is. */
|
|
49
|
+
const WHERE = `export const where = { url: import.meta.url, dirname: import.meta.dirname, filename: import.meta.filename };\n`;
|
|
50
|
+
|
|
51
|
+
/** A module with a main guard of its own, the shape of `isMain(import.meta.url)`. */
|
|
52
|
+
const GUARDED = `import { pathToFileURL } from "node:url";
|
|
53
|
+
if (import.meta.url === pathToFileURL(process.argv[1]).href) console.log("guarded main ran");
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
/** Two entries sharing `lib/where.mjs`; the first also imports a guarded module. */
|
|
57
|
+
function fixture(extra: Readonly<Record<string, string>> = {}): string {
|
|
58
|
+
return writeTree(useTempDir("paperlint-bundle-"), {
|
|
59
|
+
"package.json": `{ "type": "module" }\n`,
|
|
60
|
+
"app/one/main.ts": `import { where } from "../../lib/where.mjs";\nimport "../../lib/guarded.mjs";\nconst n: string = "one";\nconsole.log(JSON.stringify({ entry: n, ...where }));\n`,
|
|
61
|
+
"app/two/main.mjs": `import { where } from "../../lib/where.mjs";\nconsole.log(JSON.stringify({ entry: "two", ...where }));\n`,
|
|
62
|
+
"lib/where.mjs": WHERE,
|
|
63
|
+
"lib/guarded.mjs": GUARDED,
|
|
64
|
+
"out/chunks/stale.js": "stale\n",
|
|
65
|
+
...extra,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const plan = (root: string, over: Partial<BundlePlan> = {}): BundlePlan => ({
|
|
70
|
+
root,
|
|
71
|
+
entries: ["app/one/main.ts", "app/two/main.mjs"],
|
|
72
|
+
chunkDir: "out/chunks",
|
|
73
|
+
tracked: () => [],
|
|
74
|
+
...over,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/** What `lib/where.mjs` must report about itself, wherever its code was bundled. */
|
|
78
|
+
const whereOf = (root: string, entry: string): Record<string, string> => ({
|
|
79
|
+
entry,
|
|
80
|
+
url: pathToFileURL(join(root, "lib", "where.mjs")).href,
|
|
81
|
+
dirname: join(root, "lib"),
|
|
82
|
+
filename: join(root, "lib", "where.mjs"),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe("bundleSkills writes", () => {
|
|
86
|
+
it("writes every entry's bundle beside its source and the shared chunks, and nothing else", async () => {
|
|
87
|
+
const root = fixture();
|
|
88
|
+
const before = snapshot(root);
|
|
89
|
+
const written = await bundleSkills(plan(root));
|
|
90
|
+
// Guards: the run's own report and the disk agree, the stale chunk is gone, no file was edited.
|
|
91
|
+
expect(delta(before, snapshot(root))).toEqual({
|
|
92
|
+
added: written,
|
|
93
|
+
removed: ["out/chunks/stale.js"],
|
|
94
|
+
changed: [],
|
|
95
|
+
});
|
|
96
|
+
// Guards: each entry's bundle sits beside its source as `.js`; every other output is a chunk.
|
|
97
|
+
expect({
|
|
98
|
+
entries: written.filter((p) => !p.startsWith("out/chunks/")),
|
|
99
|
+
chunks: written.filter((p) => p.startsWith("out/chunks/")).length > 0,
|
|
100
|
+
}).toEqual({
|
|
101
|
+
entries: ["app/one/main.js", "app/two/main.js"],
|
|
102
|
+
chunks: true,
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("runs only the entry's own main, and each module keeps its own location", async () => {
|
|
107
|
+
const root = fixture();
|
|
108
|
+
await bundleSkills(plan(root));
|
|
109
|
+
const run = (entry: string) =>
|
|
110
|
+
runNode(join(root, entry), [], { cwd: root });
|
|
111
|
+
// Guards: the guarded module's main did not run, and `where` names its own source, not the bundle.
|
|
112
|
+
expect([run("app/one/main.js"), run("app/two/main.js")]).toEqual([
|
|
113
|
+
{
|
|
114
|
+
status: 0,
|
|
115
|
+
stdout: `${JSON.stringify(whereOf(root, "one"))}\n`,
|
|
116
|
+
stderr: "",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
status: 0,
|
|
120
|
+
stdout: `${JSON.stringify(whereOf(root, "two"))}\n`,
|
|
121
|
+
stderr: "",
|
|
122
|
+
},
|
|
123
|
+
]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("keeps a module's location in a bundle written at the root itself", async () => {
|
|
127
|
+
const root = fixture({
|
|
128
|
+
"top.mjs": `import { where } from "./lib/where.mjs";\nconsole.log(JSON.stringify({ entry: "top", ...where }));\n`,
|
|
129
|
+
});
|
|
130
|
+
await bundleSkills(plan(root, { entries: ["top.mjs"] }));
|
|
131
|
+
// Guards: from a bundle in the root folder, `where` still names lib/where.mjs.
|
|
132
|
+
expect(runNode(join(root, "top.js"), [], { cwd: root })).toEqual({
|
|
133
|
+
status: 0,
|
|
134
|
+
stdout: `${JSON.stringify(whereOf(root, "top"))}\n`,
|
|
135
|
+
stderr: "",
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe("bundleSkills refuses", () => {
|
|
141
|
+
it("writing nothing, when an output is a tracked file", async () => {
|
|
142
|
+
const root = fixture();
|
|
143
|
+
const before = snapshot(root);
|
|
144
|
+
const tracked = (_: string, paths: readonly string[]): readonly string[] =>
|
|
145
|
+
paths.filter((p) => p === "app/one/main.js");
|
|
146
|
+
// Guards: the refusal names the tracked path, and the tree is byte-identical afterwards.
|
|
147
|
+
await expect(bundleSkills(plan(root, { tracked }))).rejects.toThrow(
|
|
148
|
+
"bundle-skills: refused\n app/one/main.js is tracked by git: a bundle must not overwrite it",
|
|
149
|
+
);
|
|
150
|
+
expect(snapshot(root)).toEqual(before);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("an entry that another bundled module imports", async () => {
|
|
154
|
+
const root = fixture();
|
|
155
|
+
// Guards: an entry whose code would move into a chunk is named, not bundled.
|
|
156
|
+
await expect(
|
|
157
|
+
bundleSkills(
|
|
158
|
+
plan(root, { entries: ["app/one/main.ts", "lib/where.mjs"] }),
|
|
159
|
+
),
|
|
160
|
+
).rejects.toThrow(
|
|
161
|
+
"bundle-skills: refused\n lib/where.mjs is an entry and is imported by another bundled module: its code would leave its own file",
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it.each([
|
|
166
|
+
[
|
|
167
|
+
"import.meta.resolve",
|
|
168
|
+
`export const where = { r: import.meta.resolve("./x.mjs") };\n`,
|
|
169
|
+
"import.meta.resolve",
|
|
170
|
+
],
|
|
171
|
+
[
|
|
172
|
+
"a bare import.meta",
|
|
173
|
+
`export const where = { m: import.meta };\n`,
|
|
174
|
+
"import.meta",
|
|
175
|
+
],
|
|
176
|
+
])("%s in a module that is not the entry", async (_, source, named) => {
|
|
177
|
+
const root = fixture({ "lib/where.mjs": source });
|
|
178
|
+
// Guards: a use of import.meta the step cannot keep correct is refused with the module's path.
|
|
179
|
+
await expect(bundleSkills(plan(root))).rejects.toThrow(
|
|
180
|
+
`lib/where.mjs: ${named} cannot be kept correct inside a bundle`,
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe("gitTracked", () => {
|
|
186
|
+
it("names the tracked paths of those asked, and none outside a checkout", () => {
|
|
187
|
+
// Guards: a tracked file is reported, an absent one is not.
|
|
188
|
+
expect(gitTracked(ROOT, ["package.json", "no-such-file.js"])).toEqual([
|
|
189
|
+
"package.json",
|
|
190
|
+
]);
|
|
191
|
+
// Guards: a source archive or a git-dependency install has no `.git`, and npm runs
|
|
192
|
+
// `prepare` there; with no checkout no output can overwrite a tracked file.
|
|
193
|
+
const bare = useTempDir("paperlint-nogit-");
|
|
194
|
+
writeFileSync(join(bare, "x"), "");
|
|
195
|
+
expect(gitTracked(bare, ["x"])).toEqual([]);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
describe("npm run build's bundle step, on this checkout", () => {
|
|
200
|
+
it("writes every skill entry's bundle and touches no tracked file", () => {
|
|
201
|
+
const status = (): string =>
|
|
202
|
+
execFileSync("git", ["status", "--porcelain", "--untracked-files=no"], {
|
|
203
|
+
cwd: ROOT,
|
|
204
|
+
encoding: "utf8",
|
|
205
|
+
});
|
|
206
|
+
const before = status();
|
|
207
|
+
const r = runNode(join(ROOT, "scripts", "bundle-skills.ts"));
|
|
208
|
+
const listed = r.stderr
|
|
209
|
+
.split("\n")
|
|
210
|
+
.slice(1)
|
|
211
|
+
.map((l) => l.trim())
|
|
212
|
+
.filter(Boolean);
|
|
213
|
+
const bundles = SKILL_ENTRIES.map((e) => e.replace(/\.(ts|mjs)$/, ".js"));
|
|
214
|
+
// Guards: the step succeeded, kept stdout empty (npm pack --json), and wrote every entry's bundle.
|
|
215
|
+
expect({
|
|
216
|
+
status: r.status,
|
|
217
|
+
stdout: r.stdout,
|
|
218
|
+
bundles: bundles.filter((b) => listed.includes(b)),
|
|
219
|
+
others: listed.filter(
|
|
220
|
+
(p) => !bundles.includes(p) && !p.startsWith(`${CHUNK_DIR}/`),
|
|
221
|
+
),
|
|
222
|
+
}).toEqual({ status: 0, stdout: "", bundles, others: [] });
|
|
223
|
+
// Guards: no tracked file changed.
|
|
224
|
+
expect(status()).toBe(before);
|
|
225
|
+
});
|
|
226
|
+
});
|