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.
Files changed (75) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CLAUDE.md +2 -2
  3. package/dist/adapters/eslint/index.d.ts +13 -0
  4. package/dist/adapters/eslint/index.d.ts.map +1 -0
  5. package/dist/adapters/eslint/index.js +44 -0
  6. package/dist/adapters/eslint/index.js.map +1 -0
  7. package/dist/adapters/eslint/report.io.d.ts +15 -0
  8. package/dist/adapters/eslint/report.io.d.ts.map +1 -0
  9. package/dist/adapters/eslint/report.io.js +48 -0
  10. package/dist/adapters/eslint/report.io.js.map +1 -0
  11. package/dist/cli.d.ts +7 -12
  12. package/dist/cli.d.ts.map +1 -1
  13. package/dist/cli.js +80 -121
  14. package/dist/cli.js.map +1 -1
  15. package/dist/domain/submission-lint.d.ts +29 -0
  16. package/dist/domain/submission-lint.d.ts.map +1 -0
  17. package/dist/domain/submission-lint.js +84 -0
  18. package/dist/domain/submission-lint.js.map +1 -0
  19. package/dist/folder-layout-hook.js +1 -1
  20. package/dist/hooks-notice.d.ts +2 -0
  21. package/dist/hooks-notice.d.ts.map +1 -1
  22. package/dist/hooks-notice.js +4 -1
  23. package/dist/hooks-notice.js.map +1 -1
  24. package/dist/ports/submission-lint.d.ts +6 -0
  25. package/dist/ports/submission-lint.d.ts.map +1 -0
  26. package/dist/ports/submission-lint.js +2 -0
  27. package/dist/ports/submission-lint.js.map +1 -0
  28. package/dist/structure.d.ts +17 -1
  29. package/dist/structure.d.ts.map +1 -1
  30. package/dist/structure.js.map +1 -1
  31. package/dist/submission-confirm-hook.d.ts +8 -1
  32. package/dist/submission-confirm-hook.d.ts.map +1 -1
  33. package/dist/submission-confirm-hook.js +75 -20
  34. package/dist/submission-confirm-hook.js.map +1 -1
  35. package/dist/submission.d.ts +5 -0
  36. package/dist/submission.d.ts.map +1 -1
  37. package/dist/submission.js +46 -7
  38. package/dist/submission.js.map +1 -1
  39. package/dist/types.d.ts +2 -0
  40. package/dist/types.d.ts.map +1 -1
  41. package/docs/install.md +4 -4
  42. package/docs/layout.md +0 -1
  43. package/docs/submission.md +19 -8
  44. package/eslint.config.mjs +2 -0
  45. package/hooks/hooks.harness.ts +2 -140
  46. package/hooks/paper-skills-nudge.hook.mjs +0 -6
  47. package/lib/paper-config.harness.mjs +1 -2
  48. package/package.json +1 -1
  49. package/plugin/hooks/hooks.json +0 -9
  50. package/scripts/eslint-file-length.mjs +117 -0
  51. package/src/adapters/eslint/index.test.ts +152 -0
  52. package/src/adapters/eslint/index.ts +89 -0
  53. package/src/adapters/eslint/report.io.ts +82 -0
  54. package/src/cli.harness.mjs +9 -8
  55. package/src/cli.test.ts +4 -4
  56. package/src/cli.ts +110 -144
  57. package/src/domain/submission-lint.test.ts +211 -0
  58. package/src/domain/submission-lint.ts +166 -0
  59. package/src/folder-layout-hook.ts +1 -1
  60. package/src/hooks-notice.test.ts +2 -2
  61. package/src/hooks-notice.ts +10 -1
  62. package/src/hooks-settings.harness.ts +8 -8
  63. package/src/ports/submission-lint.ts +10 -0
  64. package/src/structure.ts +2 -4
  65. package/src/submission-confirm-hook-lint.test.ts +47 -0
  66. package/src/submission-confirm-hook.test.ts +73 -6
  67. package/src/submission-confirm-hook.ts +133 -28
  68. package/src/submission-fields-run.test.ts +1 -1
  69. package/src/submission-new.test.ts +4 -2
  70. package/src/submission-update.test.ts +16 -11
  71. package/src/submission.ts +62 -8
  72. package/src/types.ts +2 -0
  73. package/hooks/paper-status-gates.hook.mjs +0 -158
  74. package/hooks/paper-status-gates.sh +0 -93
  75. package/hooks/paper-status-gates.test.ts +0 -101
@@ -1,158 +0,0 @@
1
- /**
2
- * paper-status-gates — a PostToolUse react: editing a paper's source surfaces that paper's
3
- * readiness verdict and its UNRUN GATES, unprompted.
4
- *
5
- * A ☐ against study-accepted / pc-panel / harden / verify-citations is a HOLE, not an
6
- * "anti-churn" skip: a session that skipped three of them had the panel come back with real
7
- * must-fixes. Advisory, never blocks, always exits 0 — a `react`'s type has no `deny`.
8
- *
9
- * ── WHY IT WAS WORTH SURFACING AT ALL ───────────────────────────────────────
10
- * The checker PARSED the verdict line (to test it was not a bare percentage) and never PRINTED
11
- * it, so the one fact its author kept asking for by hand was the one thing the tooling reliably
12
- * withheld. A status file nobody is shown is a status file nobody reads.
13
- *
14
- * ── THE PURE / IMPURE LINE, AND WHERE IT REALLY FALLS ───────────────────────
15
- * An earlier header claimed this half "READS A FILE and interpolates its contents, and a vigiles
16
- * `react` is a pure function — it cannot", and called that the honest boundary of the closed
17
- * vocabulary. That reading was one step too pessimistic. The boundary is real, but it falls
18
- * between DECIDING and DOING, not between "hook" and "shell": deciding whether this edit
19
- * concerns a paper, and WHICH one, is pure and belongs here; reading that paper's status file
20
- * and running the checker is a tool, and `run()` is how a react invokes one.
21
- *
22
- * ── WHY THE DIRECTORY NAME IS VALIDATED BEFORE IT REACHES A COMMAND ─────────
23
- * `run()` takes a string AND IT GOES THROUGH A SHELL — measured 2026-09-12: a `$(…)` inside a
24
- * `run()` command substitutes. This one embeds a path taken from the event, so the name is
25
- * extracted by an anchored pattern and accepted only if it is `[A-Za-z0-9._-]+` — no slash, no
26
- * space, no shell metacharacter can survive. The shell predecessor got this incidentally, via a
27
- * `grep -oE`; here it is explicit, because "incidentally safe" is how it stops being safe.
28
- *
29
- * 🔴 THE `(?:^|\/)` IS NOT DECORATION, AND LEAVING IT OUT KILLED THIS HOOK ONCE. The first
30
- * version anchored the papers root at `^`, which passed every test in the harness — because the
31
- * harness's own edit helper builds a RELATIVE path. The live harness sends an ABSOLUTE one.
32
- * Measured against the real runtime:
33
- *
34
- * file_path "<root>/<paper>/paper.tex" → fires
35
- * file_path "/abs/path/to/repo/<root>/<paper>/…" → SILENT
36
- *
37
- * So the hook would have been dead in production and green in the tests: precisely the
38
- * false-confidence class this whole exercise is about, reintroduced while converting a hook away
39
- * from it. The shell version was accidentally immune — it grepped the raw payload with no anchor
40
- * at all. The harness now sends BOTH spellings for every case.
41
- *
42
- * The boundary is still required (`^` or `/`), so a directory merely ENDING in the root's last
43
- * segment cannot smuggle a match.
44
- *
45
- * ── WHAT THIS HOOK'S OUTPUT DOES *NOT* DO, measured and named ───────────────
46
- * ⚠️ A `run()` reaction's output is passed through RAW — 0 bytes of `hookSpecificOutput` on
47
- * stdout, the tool's own text on stderr (measured 2026-09-12: 1 184 bytes of stderr, 0 of
48
- * stdout). Only a `notice` on an injectable event becomes `additionalContext`. So this hook's
49
- * findings reach a HUMAN reading the transcript's debug output, not the model's context. That is
50
- * a property of the reaction KIND, not a bug here, and it is the reason the static half lives in
51
- * `paper-skills-nudge` as a `notice` instead: that one does land.
52
- *
53
- * ── WHY `.mjs` AND NOT A `.hook.ts` SPEC ────────────────────────────────────
54
- * See `paper-edit-guard.hook.mjs`: a `.ts` hook reached through `node_modules` does not load,
55
- * and a consumer-side thin spec importing this logic is refused by `vigiles compile` and can
56
- * never be re-stamped. Both halves measured there.
57
- */
58
- import {
59
- experimental_defineReact,
60
- tools,
61
- provide,
62
- run,
63
- nothing,
64
- } from "vigiles/hook";
65
-
66
- /** The tool's name — the package this hook resolves its scripts through. */
67
- export const CONFIG_KEY = "paperlint";
68
- /** The settings file at the project root. Optional: absent means every default. */
69
- export const CONFIG_FILE = "paperlint.json";
70
- /** The default. A consumer that declares nothing is assumed to keep papers in `papers/`. */
71
- export const DEFAULT_PAPERS_ROOT = "papers";
72
- /**
73
- * The field of the root `paperlint.json` that names the papers directory. These are copies of the
74
- * constants in `lib/paper-config.mjs` (a hook may import nothing but `vigiles/hook`);
75
- * `lib/paper-config.harness.mjs` checks that the copies match.
76
- */
77
- export const PAPERS_DIR_FIELD = "papersDir";
78
-
79
- /**
80
- * The provider: the root `paperlint.json`, or `{}` when the project has none — so an ABSENT file
81
- * (every default) and an UNREADABLE one (the empty string the runtime gives a failed provider)
82
- * stay two different inputs.
83
- *
84
- * 🔴 THE PATH IS ANCHORED TO THE PROJECT ROOT. vigiles runs a provider "via execSync in the hook's
85
- * cwd", which is the consumer's wiring — a string this hook cannot see. A bare relative path reads
86
- * from whatever directory the Bash tool last moved to.
87
- */
88
- const READ_CONFIG = `f="\${CLAUDE_PROJECT_DIR:-.}/${CONFIG_FILE}"; if [ -e "$f" ]; then cat "$f"; else echo '{}'; fi`;
89
-
90
- /**
91
- * The declared papers root, or `null` when it is unusable.
92
- *
93
- * ⚠️ `null` means SILENCE, not refusal — same asymmetry as `paper-skills-nudge` and for the same
94
- * reason: this is advisory, and a `react` cannot deny anyway. The gate (`paper-edit-guard`) is
95
- * the one that must refuse on an unreadable declaration, because there a silent default would
96
- * pass the very writes it exists to stop.
97
- *
98
- * 🔴 `declared === undefined`, NOT `declared ?? DEFAULT` — `"papersDir": null` is a keystroke, not
99
- * an absence.
100
- */
101
- const papersRoot = (rawConfig) => {
102
- let declared;
103
- try {
104
- declared = JSON.parse(rawConfig)?.[PAPERS_DIR_FIELD];
105
- } catch {
106
- return null;
107
- }
108
- const root = declared === undefined ? DEFAULT_PAPERS_ROOT : declared;
109
- if (typeof root !== "string" || root.length === 0) return null;
110
- return root.replace(/\/+$/, "");
111
- };
112
-
113
- /**
114
- * A paper SOURCE under `<root>/<dir>/`, with `<dir>` captured.
115
- *
116
- * 🔴 THE ROOT IS REGEX-ESCAPED. It is a path from a config file, and `.` is both a legal
117
- * directory character and a regex wildcard: an unescaped root like `docs.v2/papers` would match
118
- * `docsXv2/papers` too. Cheap to get right, and the failure it prevents is a hook firing about
119
- * the wrong tree.
120
- */
121
- const paperSourceRe = (root) =>
122
- new RegExp(
123
- `(?:^|/)${root.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/([A-Za-z0-9._-]+)/[^/]*\\.tex$`,
124
- );
125
-
126
- /**
127
- * The tool invocation, with the script located rather than assumed.
128
- *
129
- * 🔴 `require.resolve` INSTEAD OF A HARD-CODED `node_modules/<pkg>/…` PATH. This package must
130
- * not spell its own install location: a consumer may install it under an alias, and a
131
- * pnpm/yarn-berry layout is not `node_modules/<name>` at all. `require.resolve` asks the
132
- * resolver the same question Node itself answers, and it works for a non-JS extension —
133
- * measured 2026-09-12 against a `.md` and a `.sh` in an installed copy. It runs in a `$(…)`
134
- * because `run()` goes through a shell (also measured).
135
- */
136
- const surface = (dir) =>
137
- `bash "$(node -p "require.resolve('${CONFIG_KEY}/hooks/paper-status-gates.sh')")" --surface ${dir}`;
138
-
139
- export default experimental_defineReact({
140
- on: "PostToolUse",
141
- match: tools("Edit", "Write", "MultiEdit"),
142
- // The provider is anchored to the project root (`READ_CONFIG`, above).
143
- //
144
- // ⚠️ THE FAILURE HERE IS SILENT, which makes it more dangerous than its neighbor's.
145
- // `paper-edit-guard` on PreToolUse DENIES loudly and visibly when the declaration is
146
- // unreadable. This hook on PostToolUse just returns `nothing()`, i.e. simply stops firing:
147
- // the `cat` fails → empty string → `JSON.parse("")` throws → `papersRoot` returns null
148
- // → silence. And silence is exactly what a nudge's success state looks like, so a dead hook
149
- // is indistinguishable from a working one.
150
- needs: [provide("config", READ_CONFIG)],
151
- react: (e) => {
152
- const root = papersRoot(e.ctx.config);
153
- if (root === null) return nothing();
154
- const m = paperSourceRe(root).exec(e.path.raw.replace(/^\.\//, ""));
155
- if (m === null) return nothing();
156
- return run(surface(m[1]));
157
- },
158
- });
@@ -1,93 +0,0 @@
1
- #!/usr/bin/env bash
2
- # paper-status-gates.sh — NOT A HOOK. This is a TOOL invoked by `paper-status-gates.hook.mjs`,
3
- # which owns the event routing and decides WHICH paper (if any) an edit concerned.
4
- #
5
- # --surface <paper-dir> print the readiness verdict and the unrun gates
6
- #
7
- # 🔴 WHAT LEFT THIS FILE AND WHY IT MATTERS. It used to read its payload with
8
- # `INPUT="${CLAUDE_TOOL_INPUT:-}"` plus a `timeout 1 cat` fallback and then grep that blob for a
9
- # paper path. `$CLAUDE_TOOL_INPUT` is NOT set by the harness — the payload arrives on stdin — and
10
- # that single idiom left THREE hooks silently dead for twelve days. None of it survives here:
11
- # this file receives an already-validated directory NAME as an argument, and it is registered as
12
- # a hook nowhere, so it cannot contract that disease again.
13
- #
14
- # Advisory (stderr), never blocks, always exits 0.
15
- set -euo pipefail
16
-
17
- [ "${1:-}" = "--surface" ] || {
18
- echo "paper-status-gates.sh: a tool, not a hook. Use --surface <paper-dir>." >&2
19
- exit 0
20
- }
21
-
22
- pdir_name="${2:-}"
23
- [ -n "$pdir_name" ] || exit 0
24
- # Defence in depth: the hook already anchored this to [A-Za-z0-9._-]+, and it is re-checked here
25
- # so the file is safe to call directly too.
26
- case "$pdir_name" in
27
- *[!A-Za-z0-9._-]* | "" | . | ..) exit 0 ;;
28
- esac
29
-
30
- # ── WHERE THE CONSUMER'S THINGS ARE — READ, NOT ASSUMED ─────────────────────
31
- # The papers path comes from the one declaration every other carrier of this package reads, the
32
- # project's root paperlint.json (optional — absent means the default):
33
- #
34
- # { "papersDir": "docs/papers" }
35
- #
36
- # ⚠️ `node -p` RATHER THAN grep/sed ON THE FILE. A JSON value is not a line of text: it can
37
- # be quoted, escaped, or spread across lines, and a pattern that gets it right today gets it
38
- # wrong on the first reformat — silently, by producing a root that matches nothing. Node is
39
- # already a hard dependency of the hook that runs this script, so there is no new requirement.
40
- ROOT_DIR="${CLAUDE_PROJECT_DIR:-.}"
41
- read_key() { # $1 = key, $2 = default
42
- node -p "((c) => c['$1'] ?? '$2')((() => { try { return require('$ROOT_DIR/paperlint.json') } catch { return {} } })())" \
43
- 2>/dev/null || echo "$2"
44
- }
45
- papers_root="$(read_key papersDir papers)"
46
-
47
- # 🔴 AN UNUSABLE ROOT EXITS, IT DOES NOT BUILD A PATH FROM IT. `node -p` prints `undefined` for a
48
- # key whose value is literally `null` (`?? ` only catches null/undefined AFTER the object lookup,
49
- # and a `null` value reaches the default — but a malformed paperlint.json reads as {} and
50
- # hands back the default). Either way, an empty or nonsense value would
51
- # produce `/<paper>/PIPELINE-STATUS.md` rooted at the filesystem, which does not exist, and this
52
- # script would exit 0 looking like a paper with nothing to report. Named rather than risked.
53
- case "$papers_root" in
54
- "" | undefined | null) exit 0 ;;
55
- esac
56
-
57
- pdir="$papers_root/$pdir_name"
58
- STATUS="$ROOT_DIR/$pdir/PIPELINE-STATUS.md"
59
- [ -f "$STATUS" ] || exit 0
60
-
61
- # 🔴 SURFACE THE VERDICT, UNPROMPTED — see the header: the checker parsed this line and never
62
- # printed it, so the single fact anyone actually wanted was the one the tooling withheld.
63
- VERDICT=$(grep -m1 -E '^\*\*Readiness verdict:\*\*' "$STATUS" 2>/dev/null || true)
64
- if [ -n "$VERDICT" ]; then
65
- echo "📊 $(echo "$VERDICT" | sed -E 's/\*\*//g' | cut -c1-200)" >&2
66
- else
67
- echo "📊 PIPELINE-STATUS.md has NO '**Readiness verdict:**' line — the scorecard cannot say" >&2
68
- echo " whether this paper is submittable, which is the one question it exists to answer." >&2
69
- fi
70
-
71
- # The gates a table row marks ☐ (not run), each with the skill that owns it. A report, not an order:
72
- # the final review runs once, and a row it closed (☑ closed) is not unrun. Only table rows count, so
73
- # the checklist line under the GATES table is not read as a gate.
74
- owner_of() { # $1 = the row's id; empty for a row that is not one of these gates
75
- case "$1" in
76
- structure | coldread | panel) echo "the final review, once (paper-pipeline, \"The final review\")" ;;
77
- harden) echo "the submit checklist (harden-paper)" ;;
78
- cites) echo "verify-citations, on every \\cite added or moved" ;;
79
- venuebar) echo "study-accepted-papers" ;;
80
- esac
81
- }
82
- ids=$(grep -E '^\|' "$STATUS" 2>/dev/null | grep '☐' | grep -v 'closed' |
83
- awk -F'|' '{ gsub(/ /, "", $2); print $2 }' || true)
84
- report=""
85
- for g in $ids; do
86
- o=$(owner_of "$g")
87
- [ -n "$o" ] && report="$report $g — $o"$'\n'
88
- done
89
- if [ -n "$report" ]; then
90
- echo "📋 Not run yet in $pdir/PIPELINE-STATUS.md (☐):" >&2
91
- printf '%s' "$report" >&2
92
- fi
93
- exit 0
@@ -1,101 +0,0 @@
1
- /**
2
- * paper-status-gates on the two declarations the hooks harness does not carry: none at all (the
3
- * default `papers/` root applies) and one that does not parse (silence — this hook never blocks).
4
- * Then the report of unrun gates: it fires on a planted ☐ and stays quiet on a clean or closed status.
5
- */
6
- import assert from "node:assert/strict";
7
- import { join } from "node:path";
8
- import { test } from "vitest";
9
- import { hookConsumer, onEdit, runShippedHook } from "../test/hook-consumer.ts";
10
- import { useTempDir } from "../test/support.ts";
11
-
12
- const root = useTempDir("paper-status-gates-");
13
- const STATUS = "**Readiness verdict:** ✅ fixture verdict line\n";
14
-
15
- test("no paperlint.json: an edit under papers/ runs the gates for that paper", () => {
16
- const dir = hookConsumer(join(root, "default"), {
17
- "papers/alpha/PIPELINE-STATUS.md": STATUS,
18
- });
19
- const r = runShippedHook(
20
- "paper-status-gates",
21
- onEdit("papers/alpha/paper.tex"),
22
- dir,
23
- );
24
- assert.equal(r.exitCode, 0);
25
- assert.match(r.stderr, /fixture verdict line/);
26
- });
27
-
28
- test("a paperlint.json that does not parse: silent, exit 0", () => {
29
- const dir = hookConsumer(join(root, "broken"), {
30
- "paperlint.json": "{ nope",
31
- "papers/alpha/PIPELINE-STATUS.md": STATUS,
32
- });
33
- const r = runShippedHook(
34
- "paper-status-gates",
35
- onEdit("papers/alpha/paper.tex"),
36
- dir,
37
- );
38
- assert.deepEqual([r.exitCode, r.stdout, r.stderr], [0, "", ""]);
39
- });
40
-
41
- test("an edit to a file of the paper other than its source: no gates run", () => {
42
- const dir = hookConsumer(join(root, "not-a-source"), {
43
- "papers/alpha/PIPELINE-STATUS.md": STATUS,
44
- });
45
- const r = runShippedHook(
46
- "paper-status-gates",
47
- onEdit("papers/alpha/notes.txt"),
48
- dir,
49
- );
50
- assert.deepEqual([r.exitCode, r.stdout, r.stderr], [0, "", ""]);
51
- });
52
-
53
- /** A status file with the verdict line and the given GATES rows. */
54
- const statusWith = (...rows: readonly string[]): string =>
55
- [
56
- STATUS,
57
- "| id | Gate | Skill | Requires | Status | Date | Result | Open |",
58
- "| -- | ---- | ----- | -------- | ------ | ---- | ------ | ---- |",
59
- ...rows,
60
- "",
61
- ].join("\n");
62
-
63
- const gatesOf = (name: string, status: string) =>
64
- runShippedHook(
65
- "paper-status-gates",
66
- onEdit("papers/alpha/paper.tex"),
67
- hookConsumer(join(root, name), {
68
- "papers/alpha/PIPELINE-STATUS.md": status,
69
- }),
70
- );
71
-
72
- test("unrun gates are reported with their owner, and nothing orders a rerun", () => {
73
- const r = gatesOf(
74
- "unrun",
75
- statusWith(
76
- "| panel | Review decision | pc-panel-review | structure, coldread | ☐ | — | — | — |",
77
- "| harden | Submit checklist | harden-paper | panel, cites | ☐ | — | — | — |",
78
- ),
79
- );
80
- assert.equal(r.exitCode, 0);
81
- assert.deepEqual(r.stderr.split("\n").slice(1), [
82
- "📋 Not run yet in papers/alpha/PIPELINE-STATUS.md (☐):",
83
- ' panel — the final review, once (paper-pipeline, "The final review")',
84
- " harden — the submit checklist (harden-paper)",
85
- "",
86
- ]);
87
- });
88
-
89
- test("a clean status and a closed final review report no gate", () => {
90
- const r = gatesOf(
91
- "closed",
92
- statusWith(
93
- "| panel | Review decision | pc-panel-review | structure, coldread | ☑ closed 2026-11-19 | 2026-11-19 | weak accept | — |",
94
- "| harden | Submit checklist | harden-paper | panel, cites | ☑ | 2026-11-19 | ready | — |",
95
- ),
96
- );
97
- assert.deepEqual(
98
- [r.exitCode, r.stderr],
99
- [0, "📊 Readiness verdict: ✅ fixture verdict line\n"],
100
- );
101
- });