paperlint 19.0.1 → 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.
@@ -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
- });