paperlint 3.1.3 → 3.2.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.
Files changed (371) hide show
  1. package/.github/workflows/ci.yml +12 -7
  2. package/CLAUDE.md +3 -3
  3. package/CONTRIBUTING.md +34 -5
  4. package/dist/adapters/banal/index.d.ts.map +1 -1
  5. package/dist/adapters/banal/index.js +9 -5
  6. package/dist/adapters/banal/index.js.map +1 -1
  7. package/dist/adapters/banal/invocation.d.ts +1 -1
  8. package/dist/adapters/node/files.io.d.ts.map +1 -1
  9. package/dist/adapters/node/files.io.js +2 -1
  10. package/dist/adapters/node/files.io.js.map +1 -1
  11. package/dist/adapters/node/process.io.d.ts +0 -5
  12. package/dist/adapters/node/process.io.d.ts.map +1 -1
  13. package/dist/adapters/node/process.io.js +4 -3
  14. package/dist/adapters/node/process.io.js.map +1 -1
  15. package/dist/adapters/pdfjs/fill.d.ts.map +1 -1
  16. package/dist/adapters/pdfjs/fill.js +13 -7
  17. package/dist/adapters/pdfjs/fill.js.map +1 -1
  18. package/dist/adapters/references/index.d.ts.map +1 -1
  19. package/dist/adapters/references/index.js +4 -5
  20. package/dist/adapters/references/index.js.map +1 -1
  21. package/dist/adapters/references/pool.d.ts.map +1 -1
  22. package/dist/adapters/references/pool.js +4 -5
  23. package/dist/adapters/references/pool.js.map +1 -1
  24. package/dist/adapters/references/reach.io.d.ts.map +1 -1
  25. package/dist/adapters/references/reach.io.js +2 -1
  26. package/dist/adapters/references/reach.io.js.map +1 -1
  27. package/dist/build-engine.js +2 -2
  28. package/dist/build-engine.js.map +1 -1
  29. package/dist/build.d.ts.map +1 -1
  30. package/dist/build.js +14 -11
  31. package/dist/build.js.map +1 -1
  32. package/dist/cli.d.ts.map +1 -1
  33. package/dist/cli.js +31 -34
  34. package/dist/cli.js.map +1 -1
  35. package/dist/doctor.d.ts.map +1 -1
  36. package/dist/doctor.js +3 -2
  37. package/dist/doctor.js.map +1 -1
  38. package/dist/domain/lookup-cache.d.ts.map +1 -1
  39. package/dist/domain/lookup-cache.js +10 -8
  40. package/dist/domain/lookup-cache.js.map +1 -1
  41. package/dist/domain/text.d.ts +12 -0
  42. package/dist/domain/text.d.ts.map +1 -1
  43. package/dist/domain/text.js +17 -0
  44. package/dist/domain/text.js.map +1 -1
  45. package/dist/engine.d.ts.map +1 -1
  46. package/dist/engine.js +4 -3
  47. package/dist/engine.js.map +1 -1
  48. package/dist/eslint-rules/bib-reachable-entry.d.ts +22 -0
  49. package/dist/eslint-rules/bib-reachable-entry.d.ts.map +1 -0
  50. package/dist/eslint-rules/bib-reachable-entry.js +75 -0
  51. package/dist/eslint-rules/bib-reachable-entry.js.map +1 -0
  52. package/dist/eslint-rules/install-path-literals.d.ts +80 -0
  53. package/dist/eslint-rules/install-path-literals.d.ts.map +1 -0
  54. package/dist/eslint-rules/install-path-literals.js +105 -0
  55. package/dist/eslint-rules/install-path-literals.js.map +1 -0
  56. package/dist/eslint-rules/latex-language.d.ts +136 -0
  57. package/dist/eslint-rules/latex-language.d.ts.map +1 -0
  58. package/dist/eslint-rules/latex-language.js +639 -0
  59. package/dist/eslint-rules/latex-language.js.map +1 -0
  60. package/dist/eslint-rules/paper-research-question.d.ts +31 -0
  61. package/dist/eslint-rules/paper-research-question.d.ts.map +1 -0
  62. package/dist/eslint-rules/paper-research-question.js +188 -0
  63. package/dist/eslint-rules/paper-research-question.js.map +1 -0
  64. package/dist/eslint-rules/paper-stages.d.ts +83 -0
  65. package/dist/eslint-rules/paper-stages.d.ts.map +1 -0
  66. package/dist/eslint-rules/paper-stages.js +358 -0
  67. package/dist/eslint-rules/paper-stages.js.map +1 -0
  68. package/dist/eslint-rules/paper-typography.d.ts +74 -0
  69. package/dist/eslint-rules/paper-typography.d.ts.map +1 -0
  70. package/dist/eslint-rules/paper-typography.js +404 -0
  71. package/dist/eslint-rules/paper-typography.js.map +1 -0
  72. package/dist/eslint-rules/papers.d.ts +42 -0
  73. package/dist/eslint-rules/papers.d.ts.map +1 -0
  74. package/dist/eslint-rules/papers.js +145 -0
  75. package/dist/eslint-rules/papers.js.map +1 -0
  76. package/dist/eslint-rules/pdf-last-page-balance.d.ts +72 -0
  77. package/dist/eslint-rules/pdf-last-page-balance.d.ts.map +1 -0
  78. package/dist/eslint-rules/pdf-last-page-balance.js +237 -0
  79. package/dist/eslint-rules/pdf-last-page-balance.js.map +1 -0
  80. package/dist/eslint-rules/review-frontmatter.d.ts +57 -0
  81. package/dist/eslint-rules/review-frontmatter.d.ts.map +1 -0
  82. package/dist/eslint-rules/review-frontmatter.js +126 -0
  83. package/dist/eslint-rules/review-frontmatter.js.map +1 -0
  84. package/dist/eslint-rules/review-frontmatter.schema.json +36 -0
  85. package/dist/eslint-rules/rule-context.d.ts +55 -0
  86. package/dist/eslint-rules/rule-context.d.ts.map +1 -0
  87. package/dist/eslint-rules/rule-context.js +9 -0
  88. package/dist/eslint-rules/rule-context.js.map +1 -0
  89. package/dist/eslint-rules/sibling-frontmatter.d.ts +25 -0
  90. package/dist/eslint-rules/sibling-frontmatter.d.ts.map +1 -0
  91. package/dist/eslint-rules/sibling-frontmatter.js +16 -0
  92. package/dist/eslint-rules/sibling-frontmatter.js.map +1 -0
  93. package/dist/eslint-rules/sibling-frontmatter.schema.json +14 -0
  94. package/dist/eslint-rules/temp-root-realpath.d.ts +71 -0
  95. package/dist/eslint-rules/temp-root-realpath.d.ts.map +1 -0
  96. package/dist/eslint-rules/temp-root-realpath.js +139 -0
  97. package/dist/eslint-rules/temp-root-realpath.js.map +1 -0
  98. package/dist/eslint-rules/tex-build.d.ts +35 -0
  99. package/dist/eslint-rules/tex-build.d.ts.map +1 -0
  100. package/dist/eslint-rules/tex-build.js +313 -0
  101. package/dist/eslint-rules/tex-build.js.map +1 -0
  102. package/dist/facts-file.d.ts.map +1 -1
  103. package/dist/facts-file.js +2 -1
  104. package/dist/facts-file.js.map +1 -1
  105. package/dist/hooks-settings.d.ts +1 -1
  106. package/dist/hooks-settings.d.ts.map +1 -1
  107. package/dist/hooks-settings.js +14 -9
  108. package/dist/hooks-settings.js.map +1 -1
  109. package/dist/init.d.ts +5 -5
  110. package/dist/init.d.ts.map +1 -1
  111. package/dist/init.js +15 -7
  112. package/dist/init.js.map +1 -1
  113. package/dist/latex-loop.d.ts +2 -2
  114. package/dist/latex-loop.d.ts.map +1 -1
  115. package/dist/latex-loop.js +2 -2
  116. package/dist/latex-loop.js.map +1 -1
  117. package/dist/lib/agent-cli-version.d.ts +65 -0
  118. package/dist/lib/agent-cli-version.d.ts.map +1 -0
  119. package/dist/lib/agent-cli-version.js +77 -0
  120. package/dist/lib/agent-cli-version.js.map +1 -0
  121. package/dist/lib/check.d.ts +19 -0
  122. package/dist/lib/check.d.ts.map +1 -0
  123. package/dist/lib/check.js +52 -0
  124. package/dist/lib/check.js.map +1 -0
  125. package/dist/lib/markdown.d.ts +180 -0
  126. package/dist/lib/markdown.d.ts.map +1 -0
  127. package/dist/lib/markdown.js +302 -0
  128. package/dist/lib/markdown.js.map +1 -0
  129. package/dist/lib/paper-config.d.ts +84 -0
  130. package/dist/lib/paper-config.d.ts.map +1 -0
  131. package/dist/lib/paper-config.js +142 -0
  132. package/dist/lib/paper-config.js.map +1 -0
  133. package/dist/lib/skill-eval-fixture.d.ts +29 -0
  134. package/dist/lib/skill-eval-fixture.d.ts.map +1 -0
  135. package/dist/lib/skill-eval-fixture.js +62 -0
  136. package/dist/lib/skill-eval-fixture.js.map +1 -0
  137. package/dist/link-skills.d.ts.map +1 -1
  138. package/dist/link-skills.js +5 -4
  139. package/dist/link-skills.js.map +1 -1
  140. package/dist/new-paper.d.ts.map +1 -1
  141. package/dist/new-paper.js +2 -2
  142. package/dist/new-paper.js.map +1 -1
  143. package/dist/paper-settings.d.ts.map +1 -1
  144. package/dist/paper-settings.js +5 -4
  145. package/dist/paper-settings.js.map +1 -1
  146. package/dist/pdf-facts.d.ts.map +1 -1
  147. package/dist/pdf-facts.js +2 -1
  148. package/dist/pdf-facts.js.map +1 -1
  149. package/dist/pdf-geometry.d.ts.map +1 -1
  150. package/dist/pdf-geometry.js +1 -1
  151. package/dist/pdf-geometry.js.map +1 -1
  152. package/dist/presets.d.ts.map +1 -1
  153. package/dist/presets.js +3 -2
  154. package/dist/presets.js.map +1 -1
  155. package/dist/references.d.ts.map +1 -1
  156. package/dist/references.js +11 -6
  157. package/dist/references.js.map +1 -1
  158. package/dist/rules-config.d.ts.map +1 -1
  159. package/dist/rules-config.js +6 -3
  160. package/dist/rules-config.js.map +1 -1
  161. package/dist/structure.js +1 -1
  162. package/dist/structure.js.map +1 -1
  163. package/dist/tex-requirements.d.ts.map +1 -1
  164. package/dist/tex-requirements.js +8 -3
  165. package/dist/tex-requirements.js.map +1 -1
  166. package/dist/toolchain.d.ts.map +1 -1
  167. package/dist/toolchain.js +21 -16
  168. package/dist/toolchain.js.map +1 -1
  169. package/dist/venue-rules.js +1 -1
  170. package/dist/venue-rules.js.map +1 -1
  171. package/docs/e2e.md +7 -7
  172. package/docs/install.md +1 -1
  173. package/docs/prior-art/README.md +1 -1
  174. package/docs/prior-art/package-location.md +5 -5
  175. package/docs/prior-art/repro/README.md +1 -1
  176. package/docs/prior-art/test-tooling.md +2 -2
  177. package/docs/testing.md +11 -8
  178. package/docs/toolchain.md +1 -1
  179. package/eslint-rules/{bib-reachable-entry.mjs → bib-reachable-entry.ts} +4 -3
  180. package/eslint-rules/install-path-literals.harness.mjs +1 -1
  181. package/eslint-rules/{install-path-literals.mjs → install-path-literals.ts} +16 -8
  182. package/eslint-rules/latex-language.harness.mjs +2 -2
  183. package/eslint-rules/latex-language.test.mjs +7 -1
  184. package/eslint-rules/{latex-language.mjs → latex-language.ts} +297 -109
  185. package/eslint-rules/paper-research-question.harness.mjs +3 -3
  186. package/eslint-rules/{paper-research-question.mjs → paper-research-question.ts} +34 -15
  187. package/eslint-rules/paper-stages.harness.mjs +2 -2
  188. package/eslint-rules/paper-stages.test.mjs +8 -2
  189. package/eslint-rules/{paper-stages.mjs → paper-stages.ts} +74 -29
  190. package/eslint-rules/paper-typography.test.mjs +3 -3
  191. package/eslint-rules/{paper-typography.mjs → paper-typography.ts} +132 -54
  192. package/eslint-rules/papers.harness.mjs +2 -2
  193. package/eslint-rules/{papers.mjs → papers.ts} +7 -4
  194. package/eslint-rules/pdf-last-page-balance.harness.mjs +3 -3
  195. package/eslint-rules/{pdf-last-page-balance.mjs → pdf-last-page-balance.ts} +88 -31
  196. package/eslint-rules/review-frontmatter.test.mjs +2 -2
  197. package/eslint-rules/{review-frontmatter.mjs → review-frontmatter.ts} +37 -15
  198. package/eslint-rules/rule-context.ts +62 -0
  199. package/eslint-rules/{sibling-frontmatter.mjs → sibling-frontmatter.ts} +1 -1
  200. package/eslint-rules/temp-root-realpath.harness.mjs +1 -1
  201. package/eslint-rules/{temp-root-realpath.mjs → temp-root-realpath.ts} +19 -6
  202. package/eslint-rules/tex-build.harness.mjs +2 -2
  203. package/eslint-rules/{tex-build.mjs → tex-build.ts} +4 -3
  204. package/eslint.config.mjs +139 -30
  205. package/fixtures/pdf-facts/README.md +2 -2
  206. package/fixtures/real-markdown-paper/{baseline.mjs → baseline.ts} +31 -10
  207. package/hooks/{hooks.harness.mjs → hooks.harness.ts} +51 -34
  208. package/hooks/paper-edit-guard.hook.mjs +1 -1
  209. package/hooks/{paper-edit-guard.test.mjs → paper-edit-guard.test.ts} +3 -7
  210. package/hooks/paper-skills-nudge.hook.mjs +1 -1
  211. package/hooks/{paper-skills-nudge.test.mjs → paper-skills-nudge.test.ts} +2 -6
  212. package/hooks/{paper-status-gates.test.mjs → paper-status-gates.test.ts} +2 -6
  213. package/lib/agent-cli-version.harness.mjs +1 -1
  214. package/lib/{agent-cli-version.mjs → agent-cli-version.ts} +32 -18
  215. package/lib/check.test.ts +14 -9
  216. package/lib/{check.mjs → check.ts} +22 -9
  217. package/lib/markdown.test.mjs +7 -7
  218. package/lib/{markdown.mjs → markdown.ts} +68 -29
  219. package/lib/paper-config.harness.mjs +8 -8
  220. package/lib/{paper-config.mjs → paper-config.ts} +19 -14
  221. package/lib/skill-checks.mjs +1 -1
  222. package/lib/skill-checks.test.mjs +1 -1
  223. package/lib/skill-corpus.mjs +1 -1
  224. package/lib/skill-eval-kit.mjs +1 -1
  225. package/package.json +42 -10
  226. package/scripts/{check.harness.mjs → check.harness.ts} +111 -10
  227. package/scripts/{check.test.mjs → check.test.ts} +13 -10
  228. package/scripts/{check.mjs → check.ts} +116 -42
  229. package/scripts/coverage-config.test.ts +80 -37
  230. package/scripts/eslint-report-guard.test.mjs +1 -1
  231. package/scripts/harness-api.frozen.json +14 -15
  232. package/scripts/harness-api.test.ts +8 -5
  233. package/scripts/layer-legacy-frozen.test.ts +17 -13
  234. package/scripts/{layer-legacy-frozen.mjs → layer-legacy-frozen.ts} +128 -39
  235. package/scripts/release-config.test.ts +12 -4
  236. package/scripts/rules-see-files.test.mjs +1 -1
  237. package/scripts/test.test.ts +78 -0
  238. package/scripts/test.ts +87 -0
  239. package/skills/grade-paper-writing/prose-lint.mjs +1 -1
  240. package/skills/grade-paper-writing/{prose-lint.test.mjs → prose-lint.test.ts} +2 -2
  241. package/skills/paper-pipeline/description-language.eval.mjs +1 -1
  242. package/skills/paper-pipeline/framing-vs-vocabulary.eval.mjs +1 -1
  243. package/skills/paper-pipeline/grade-paper-writing-ablation.eval.mjs +1 -1
  244. package/skills/paper-pipeline/pipeline-firing.eval.mjs +1 -1
  245. package/skills/paper-pipeline/pipeline-language.eval.mjs +1 -1
  246. package/skills/paper-pipeline/scripts/README.md +1 -1
  247. package/skills/paper-pipeline/scripts/announce.test.mjs +1 -1
  248. package/skills/paper-pipeline/scripts/artifact-coverage.mjs +1 -1
  249. package/skills/paper-pipeline/scripts/{artifact-coverage.test.mjs → artifact-coverage.test.ts} +2 -2
  250. package/skills/paper-pipeline/scripts/consumer.mjs +1 -5
  251. package/skills/paper-pipeline/scripts/consumer.test.mjs +1 -1
  252. package/skills/paper-pipeline/scripts/extract-ref-facts.harness.mjs +1 -1
  253. package/skills/paper-pipeline/scripts/extract-ref-facts.mjs +1 -4
  254. package/skills/paper-pipeline/scripts/extract-ref-facts.test.mjs +1 -1
  255. package/skills/paper-pipeline/scripts/fixtures/{scorecard.mjs → scorecard.ts} +36 -7
  256. package/skills/paper-pipeline/scripts/{generated-code.test.mjs → generated-code.test.ts} +3 -3
  257. package/skills/paper-pipeline/scripts/ledger.cli.test.mjs +1 -1
  258. package/skills/paper-pipeline/scripts/pipeline-check.cli.test.mjs +2 -2
  259. package/skills/paper-pipeline/scripts/pipeline-check.harness.mjs +2 -2
  260. package/skills/paper-pipeline/scripts/pipeline-check.mjs +1 -4
  261. package/skills/paper-pipeline/scripts/population-map.mjs +1 -4
  262. package/skills/paper-pipeline/scripts/population-map.test.mjs +1 -1
  263. package/skills/paper-pipeline/scripts/{round-diff.harness.mjs → round-diff.harness.ts} +45 -18
  264. package/skills/paper-pipeline/scripts/round-diff.mjs +1 -1
  265. package/skills/paper-pipeline/scripts/round-diff.test.mjs +1 -1
  266. package/skills/paper-pipeline/scripts/run-mechanical.test.mjs +1 -1
  267. package/skills/paper-pipeline/scripts/status.test.mjs +1 -1
  268. package/skills/plan-paper-timeline/fixtures/{fake-google-calendar.mjs → fake-google-calendar.ts} +101 -70
  269. package/skills/plan-paper-timeline/plan-paper-timeline.effects.harness.mjs +3 -3
  270. package/skills/render-paper/{extract-pdf-facts.harness.mjs → extract-pdf-facts.harness.ts} +34 -9
  271. package/skills/render-paper/render-paper.harness.mjs +2 -2
  272. package/skills/tighten-paper/structure.mjs +1 -1
  273. package/skills/tighten-paper/{structure.test.mjs → structure.test.ts} +4 -3
  274. package/skills/verify-citations/scripts/{bib-authors.cli.test.mjs → bib-authors.cli.test.ts} +14 -4
  275. package/skills/verify-citations/scripts/bib-authors.d.mts +63 -0
  276. package/skills/verify-citations/scripts/bib-authors.mjs +1 -4
  277. package/skills/verify-citations/scripts/{verify-cites.cli.test.mjs → verify-cites.cli.test.ts} +32 -9
  278. package/skills/verify-citations/scripts/verify-cites.d.mts +58 -0
  279. package/src/CLAUDE.md +1 -1
  280. package/src/adapters/banal/index.test.ts +3 -6
  281. package/src/adapters/banal/index.ts +7 -4
  282. package/src/adapters/banal/invocation.test.ts +3 -1
  283. package/src/adapters/banal/invocation.ts +1 -1
  284. package/src/adapters/banal/output.test.ts +1 -1
  285. package/src/adapters/banal/run.test.ts +3 -3
  286. package/src/adapters/banal/xml.test.ts +1 -1
  287. package/src/adapters/curl/download.test.ts +4 -2
  288. package/src/adapters/node/files.io.ts +2 -2
  289. package/src/adapters/node/files.test.ts +3 -1
  290. package/src/adapters/node/process.io.ts +4 -3
  291. package/src/adapters/node/process.test.ts +1 -1
  292. package/src/adapters/node/workspace.test.ts +3 -1
  293. package/src/adapters/pdfjs/fill.test.ts +2 -2
  294. package/src/adapters/pdfjs/fill.ts +14 -7
  295. package/src/adapters/references/index.test.ts +31 -38
  296. package/src/adapters/references/index.ts +26 -58
  297. package/src/adapters/references/pool.ts +3 -5
  298. package/src/adapters/references/reach.io.ts +2 -1
  299. package/src/build-engine.harness.mjs +1 -1
  300. package/src/build-engine.test.ts +2 -2
  301. package/src/build-engine.ts +2 -2
  302. package/src/build.harness.mjs +2 -2
  303. package/src/build.test.ts +15 -14
  304. package/src/build.ts +28 -19
  305. package/src/cli.harness.mjs +6 -6
  306. package/src/cli.test.ts +13 -6
  307. package/src/cli.ts +39 -37
  308. package/src/doctor.harness.mjs +3 -3
  309. package/src/doctor.ts +3 -2
  310. package/src/domain/lookup-cache.ts +21 -11
  311. package/src/domain/result.test.ts +2 -2
  312. package/src/domain/text.test.ts +32 -0
  313. package/src/domain/text.ts +23 -0
  314. package/src/engine.harness.mjs +2 -2
  315. package/src/engine.ts +4 -3
  316. package/src/facts-file.test.ts +9 -7
  317. package/src/facts-file.ts +2 -1
  318. package/src/{hooks-settings.harness.mjs → hooks-settings.harness.ts} +39 -20
  319. package/src/hooks-settings.ts +20 -9
  320. package/src/init.test.ts +12 -9
  321. package/src/init.ts +22 -12
  322. package/src/{latex-log.harness.mjs → latex-log.harness.ts} +14 -14
  323. package/src/{latex-loop.harness.mjs → latex-loop.harness.ts} +64 -36
  324. package/src/latex-loop.ts +3 -3
  325. package/src/{link-skills.harness.mjs → link-skills.harness.ts} +19 -19
  326. package/src/link-skills.test.ts +3 -3
  327. package/src/link-skills.ts +5 -4
  328. package/src/lint-fix.test.ts +4 -6
  329. package/src/linted-set.test.ts +2 -2
  330. package/src/new-paper.harness.mjs +2 -2
  331. package/src/new-paper.test.ts +8 -10
  332. package/src/new-paper.ts +2 -2
  333. package/src/paper-files.test.ts +3 -5
  334. package/src/paper-settings-commands.test.ts +5 -4
  335. package/src/paper-settings.test.ts +5 -5
  336. package/src/paper-settings.ts +8 -9
  337. package/src/{pdf-facts.harness.mjs → pdf-facts.harness.ts} +9 -8
  338. package/src/pdf-facts.test.ts +10 -11
  339. package/src/pdf-facts.ts +2 -1
  340. package/src/{pdf-geometry.harness.mjs → pdf-geometry.harness.ts} +19 -12
  341. package/src/pdf-geometry.ts +3 -1
  342. package/src/presets.ts +3 -2
  343. package/src/references.test.ts +51 -43
  344. package/src/references.ts +14 -7
  345. package/src/{rules-config.harness.mjs → rules-config.harness.ts} +7 -13
  346. package/src/rules-config.ts +7 -4
  347. package/src/rules-off.test.ts +6 -4
  348. package/src/{structure.harness.mjs → structure.harness.ts} +26 -15
  349. package/src/structure.ts +1 -1
  350. package/src/{tex-requirements.harness.mjs → tex-requirements.harness.ts} +50 -22
  351. package/src/tex-requirements.ts +8 -5
  352. package/src/toolchain.harness.mjs +2 -2
  353. package/src/toolchain.test.ts +1 -1
  354. package/src/toolchain.ts +31 -17
  355. package/src/venue-rules.test.ts +62 -64
  356. package/src/venue-rules.ts +1 -1
  357. package/tsconfig.json +6 -3
  358. package/tsconfig.pkg.json +10 -0
  359. package/lib/check.d.mts +0 -17
  360. package/lib/paper-config.d.mts +0 -31
  361. package/scripts/layer-legacy-frozen.d.mts +0 -36
  362. package/scripts/rules-are-content-only.harness.mjs +0 -105
  363. package/scripts/rules-are-content-only.mjs +0 -148
  364. package/scripts/rules-are-content-only.test.mjs +0 -61
  365. package/scripts/test.mjs +0 -44
  366. package/scripts/test.test.mjs +0 -52
  367. /package/bin/{paperlint.test.mjs → paperlint.test.ts} +0 -0
  368. /package/lib/{skill-eval-fixture.mjs → skill-eval-fixture.ts} +0 -0
  369. /package/skills/grade-paper-writing/__snapshots__/{prose-lint.test.mjs.snap → prose-lint.test.ts.snap} +0 -0
  370. /package/skills/osf-artifact-upload/{osf-artifact-upload.harness.mjs → osf-artifact-upload.harness.ts} +0 -0
  371. /package/skills/tighten-paper/__snapshots__/{structure.test.mjs.snap → structure.test.ts.snap} +0 -0
@@ -0,0 +1,77 @@
1
+ /**
2
+ * OBSERVE the `claude` CLI version instead of merely probing for the binary.
3
+ *
4
+ * ── THE DEFECT THIS EXISTS FOR (issue #7, measured) ─────────────────────────────
5
+ * `plan-paper-timeline.effects.harness.mjs` is a CHARACTERIZATION test: its job is to go red
6
+ * when the upstream CLI changes under it. It named the version it characterized — 2.1.227 —
7
+ * in prose, and then threw away the version it actually saw:
8
+ *
9
+ * spawnSync("claude", ["--version"], { stdio: "ignore" }) // ← only `status` was read
10
+ *
11
+ * `stdio: "ignore"` discards the output, so `claude --version` ran as a PRESENCE probe. The
12
+ * string it printed was never read, never reported and never compared with the prose. Measured
13
+ * on this machine: the binary is **2.1.273**, the docblock says **2.1.227** — forty-six patch
14
+ * releases of drift, invisible to a reader of a green log.
15
+ *
16
+ * 🔴 WHY NOT PIN THE VERSION. A pin defeats the test: it is SUPPOSED to see upstream move. The
17
+ * repair is not to stop the drift but to stop the SILENCE about it — observe what is already
18
+ * spawned, carry the characterized number as a VALUE beside it, and let a reader see the two
19
+ * diverge instead of inferring it. CI installs `@anthropic-ai/claude-code` unpinned on purpose.
20
+ *
21
+ * ── WHY A MODULE AND NOT THREE LINES IN THE HARNESS ─────────────────────────────
22
+ * The three lines the issue suggests are correct and untestable where they were proposed. The
23
+ * harness that would exercise them spawns the real CLI, so its assertions about the observation
24
+ * depend on which version the machine happens to carry — and the one case that matters most,
25
+ * "the probe discards its output", cannot be staged at all when the spawn is hard-wired. With
26
+ * the spawner INJECTED, every case becomes deterministic: absent binary, drifted version,
27
+ * matching version, and the discarding probe itself.
28
+ */
29
+ /**
30
+ * The version the effects harness's characterization was written against.
31
+ *
32
+ * 🔴 A VALUE, NOT A SENTENCE, and that is the whole point of this constant. The number lived in
33
+ * a docblock, where nothing could compare it with anything. Here it is compared on every run.
34
+ * Moving it means deliberately re-characterizing — which is the edit that should be conscious.
35
+ */
36
+ export const CHARACTERIZED_CLI = "2.1.227";
37
+ /** What `claude --version` prints: `2.1.273 (Claude Code)`. */
38
+ const VERSION_IN = /\b(\d+\.\d+\.\d+)\b/;
39
+ export function observeAgentCli({ spawnSync, program = "claude", characterized = CHARACTERIZED_CLI, }) {
40
+ // 🔴 `encoding: "utf8"` IS THE FIX. With `stdio: "ignore"` — the shape this replaces — the
41
+ // child's output goes nowhere and `probe.stdout` comes back null, so everything downstream
42
+ // would be describing a string that was never read.
43
+ const probe = spawnSync(program, ["--version"], { encoding: "utf8" });
44
+ if (probe.status !== 0)
45
+ return {
46
+ present: false,
47
+ raw: "",
48
+ version: "",
49
+ characterized,
50
+ drifted: false,
51
+ note: `the \`${program}\` CLI is not installed, so no run can be observed`,
52
+ };
53
+ const raw = (probe.stdout ?? "").trim();
54
+ const version = VERSION_IN.exec(raw)?.[1] ?? "";
55
+ // ⚠️ EXIT 0 AND NOTHING ON STDOUT IS NOT A CLEAN OBSERVATION — it is exactly what the discarded
56
+ // probe looked like, and reporting `characterized against ""` would be the same lie in a new
57
+ // place. This is rule 4 of CLAUDE.md applied to the check that enforces it.
58
+ if (version === "")
59
+ throw new Error(`\`${program} --version\` exited 0 but printed no version on stdout (got ${JSON.stringify(raw)}` +
60
+ `${probe.stderr ? `, stderr ${JSON.stringify(probe.stderr.trim().slice(0, 200))}` : ""}). ` +
61
+ `A presence probe is not an observation: this is the \`stdio: "ignore"\` shape that issue #7 ` +
62
+ `is about, and a version nobody read must not be reported as one.`);
63
+ const drifted = version !== characterized;
64
+ return {
65
+ present: true,
66
+ raw,
67
+ version,
68
+ characterized,
69
+ drifted,
70
+ note: drifted
71
+ ? `observed \`${program}\` ${version} — the assertions here were characterized against ` +
72
+ `${characterized}. They still hold, which is itself the result: a characterization test that ` +
73
+ `silently still holds is indistinguishable from one nobody re-checked.`
74
+ : `observed \`${program}\` ${version} — the version these assertions were characterized against.`,
75
+ };
76
+ }
77
+ //# sourceMappingURL=agent-cli-version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-cli-version.js","sourceRoot":"","sources":["../../lib/agent-cli-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,+DAA+D;AAC/D,MAAM,UAAU,GAAG,qBAAqB,CAAC;AA6BzC,MAAM,UAAU,eAAe,CAAC,EAC9B,SAAS,EACT,OAAO,GAAG,QAAQ,EAClB,aAAa,GAAG,iBAAiB,GAKlC;IACC,2FAA2F;IAC3F,2FAA2F;IAC3F,oDAAoD;IACpD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAEtE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QACpB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,GAAG,EAAE,EAAE;YACP,OAAO,EAAE,EAAE;YACX,aAAa;YACb,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,SAAS,OAAO,oDAAoD;SAC3E,CAAC;IAEJ,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAEhD,gGAAgG;IAChG,6FAA6F;IAC7F,4EAA4E;IAC5E,IAAI,OAAO,KAAK,EAAE;QAChB,MAAM,IAAI,KAAK,CACb,KAAK,OAAO,+DAA+D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YAC9F,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK;YAC3F,8FAA8F;YAC9F,kEAAkE,CACrE,CAAC;IAEJ,MAAM,OAAO,GAAG,OAAO,KAAK,aAAa,CAAC;IAC1C,OAAO;QACL,OAAO,EAAE,IAAI;QACb,GAAG;QACH,OAAO;QACP,aAAa;QACb,OAAO;QACP,IAAI,EAAE,OAAO;YACX,CAAC,CAAC,cAAc,OAAO,MAAM,OAAO,oDAAoD;gBACtF,GAAG,aAAa,8EAA8E;gBAC9F,uEAAuE;YACzE,CAAC,CAAC,cAAc,OAAO,MAAM,OAAO,6DAA6D;KACpG,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ /** A failure detail: text, any value (rendered with `util.inspect`), or a thunk producing one. */
2
+ export type Detail = unknown;
3
+ /** `check(label, cond, detail?)`, and how many times it has been called. */
4
+ export interface Check {
5
+ (label: string, cond: unknown, detail?: Detail): void;
6
+ readonly count: number;
7
+ }
8
+ /** A failure detail as text: strings verbatim, other values through `util.inspect`, a thunk called. */
9
+ export declare function renderDetail(detail: Detail): string;
10
+ /** The label, then the detail: on the same line when it is one line, below it when it is many. */
11
+ export declare function failureMessage(label: string, detail: Detail): string;
12
+ /**
13
+ * A fresh `check(label, cond, detail?)`. `check.count` is how many times it has been called.
14
+ * `log` is where a failure is printed — stderr unless this module's own test injects one.
15
+ */
16
+ export declare function createChecker({ log, }?: {
17
+ log?: (line: string) => void;
18
+ }): Check;
19
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../lib/check.ts"],"names":[],"mappings":"AAmBA,kGAAkG;AAClG,MAAM,MAAM,MAAM,GAAG,OAAO,CAAC;AAE7B,4EAA4E;AAC5E,MAAM,WAAW,KAAK;IACpB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAKD,uGAAuG;AACvG,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAInD;AAED,kGAAkG;AAClG,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIpE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,GAAmB,GACpB,GAAE;IAAE,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,GAAG,KAAK,CAW/C"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The one assertion helper every harness uses.
3
+ *
4
+ * Until #52 each harness defined its own `check()`, and the copies had drifted: some printed a
5
+ * detail on failure and some dropped it, some joined it with " — " and some with a newline, and two
6
+ * passed the LABEL to vigiles' `recordCheck(n)`, which adds its argument to a number — so the
7
+ * recorded count became a string. One helper removes the drift instead of documenting it.
8
+ *
9
+ * What it guarantees:
10
+ * - a failure names the label AND the detail, on stderr and in the thrown assertion — the detail
11
+ * is what makes a red run diagnosable without re-running it;
12
+ * - `detail` may be a function, so an expensive rendering is paid only on failure;
13
+ * - every call is counted (`check.count`) and reported to the vigiles runner (`recordCheck`), so
14
+ * a harness's summary line and the runner's check count come from the same place.
15
+ */
16
+ import assert from "node:assert/strict";
17
+ import { inspect } from "node:util";
18
+ import { recordCheck } from "vigiles";
19
+ /** A detail given as a function, so it is only built on failure. */
20
+ const isThunk = (d) => typeof d === "function";
21
+ /** A failure detail as text: strings verbatim, other values through `util.inspect`, a thunk called. */
22
+ export function renderDetail(detail) {
23
+ const value = isThunk(detail) ? detail() : detail;
24
+ if (value === undefined || value === null || value === "")
25
+ return "";
26
+ return typeof value === "string" ? value : inspect(value, { depth: 6 });
27
+ }
28
+ /** The label, then the detail: on the same line when it is one line, below it when it is many. */
29
+ export function failureMessage(label, detail) {
30
+ const shown = renderDetail(detail);
31
+ if (!shown)
32
+ return label;
33
+ return shown.includes("\n") ? `${label}\n${shown}` : `${label} — ${shown}`;
34
+ }
35
+ /**
36
+ * A fresh `check(label, cond, detail?)`. `check.count` is how many times it has been called.
37
+ * `log` is where a failure is printed — stderr unless this module's own test injects one.
38
+ */
39
+ export function createChecker({ log = console.error, } = {}) {
40
+ const check = (label, cond, detail) => {
41
+ check.count++;
42
+ recordCheck();
43
+ if (cond)
44
+ return;
45
+ const message = failureMessage(label, detail);
46
+ log(`✗ ${message}`);
47
+ assert.fail(message);
48
+ };
49
+ check.count = 0;
50
+ return check;
51
+ }
52
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../lib/check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAWtC,oEAAoE;AACpE,MAAM,OAAO,GAAG,CAAC,CAAS,EAAsB,EAAE,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC;AAE3E,uGAAuG;AACvG,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,KAAK,GAAY,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IACrE,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,MAAc;IAC1D,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,MAAM,KAAK,EAAE,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,GAAG,GAAG,OAAO,CAAC,KAAK,MACiB,EAAE;IACtC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,IAAa,EAAE,MAAe,EAAQ,EAAE;QACpE,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,WAAW,EAAE,CAAC;QACd,IAAI,IAAI;YAAE,OAAO;QACjB,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC9C,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;IACF,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;IAChB,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,180 @@
1
+ import type { Token } from "markdown-it";
2
+ /** One ATX heading: its level, its text without the hashes, its 0-based line and line offset. */
3
+ export interface Heading {
4
+ readonly depth: number;
5
+ readonly text: string;
6
+ readonly line: number;
7
+ readonly offset: number;
8
+ }
9
+ /** A chunk of the document: the heading it starts with (`null` for the preamble), with and without it. */
10
+ export interface Section {
11
+ readonly heading: Heading | null;
12
+ readonly raw: string;
13
+ readonly body: string;
14
+ }
15
+ /** A block tokenizer with markdown-it's shape — the default, or one a test passes. */
16
+ export type Parse = (text: string) => readonly Token[];
17
+ /**
18
+ * Whether the parser resolved. A linter must check this ITSELF and say out loud that
19
+ * its heading checks are off: with no parser `headings()` returns an empty list, and
20
+ * silent emptiness reads as "the document has no headings", that is, as a clean
21
+ * document. The nudge lives in the linters, because by contract (see the header) this
22
+ * file has no right to produce a single finding.
23
+ */
24
+ export declare const MD_AVAILABLE: () => boolean;
25
+ export declare function blankFrontmatter(text: string): string;
26
+ /**
27
+ * The frontmatter body (between the fences), or `null` — if the file opens without one.
28
+ *
29
+ * Added 2026-08-20, when eight places in `.claude/**` cut the frontmatter with eight
30
+ * slightly different regexes: some knew about `\r\n`, some did not; some required a
31
+ * newline after the closing fence, some did not. The difference between them is not
32
+ * style, it is a different answer on one and the same file.
33
+ *
34
+ * ⚠️ This is NOT a parser and does not claim to be: `---` frontmatter is not markdown,
35
+ * no markdown parser models it (the analysis is in the root `CLAUDE.md`, "Considered
36
+ * and rejected: gray-matter"). The value here is one fence instead of eight, and the
37
+ * parsing of VALUES is done by `js-yaml` at the caller.
38
+ */
39
+ export declare function frontmatterBlock(text: string): string | null;
40
+ /**
41
+ * The document WITHOUT the frontmatter — the block is cut out together with the
42
+ * newline after it.
43
+ *
44
+ * Differs from {@link blankFrontmatter} in that the offsets SHIFT. Both forms are
45
+ * needed and both have been used already: blanking — where character positions are
46
+ * later shown to the user; cutting — where the text is merely counted. Choose by what
47
+ * the caller does, not by taste.
48
+ */
49
+ export declare function stripFrontmatter(text: string): string;
50
+ /**
51
+ * All the document's headings: `[{ depth, text, line, offset }]`, in order of occurrence.
52
+ *
53
+ * `offset` — the index of the start of the heading's line IN THE SAME text that was
54
+ * passed in, in `slice`/`indexOf` units (UTF-16), because those are exactly what the
55
+ * checks cut the document with. `line` — 0-based line number. `text` — without the
56
+ * hashes, trimmed at the edges.
57
+ *
58
+ * ⚠️ ATX ONLY (`## Heading`). Setext (`Heading\n---`) is deliberately NOT counted as a
59
+ * heading: in this knowledge base `---` is a prose separator, and a paragraph it stands
60
+ * under without a blank line would become a level-2 heading per CommonMark. The former
61
+ * regexps knew only ATX, so this preserves the contract rather than narrowing it.
62
+ */
63
+ export declare function headings(text: string, { parse }?: {
64
+ parse?: Parse | null;
65
+ }): Heading[];
66
+ /**
67
+ * Slicing the document into chunks "a heading + everything up to the next heading FROM
68
+ * THE SAME RANGE of levels". → `[{ heading, raw, body }]`.
69
+ *
70
+ * This is exactly what four scripts did as `split(/^(?=## )/m)` and
71
+ * `split(/^(?=#{2,3} )/m)`. The shape of the expression lied about the intent: "two or
72
+ * three hashes" is about CHARACTERS, while what is needed is the LEVEL, and `#{2,3}`
73
+ * also caught a hash inside a ```-block, that is, it cut a quotation from someone
74
+ * else's paper as a section of its own.
75
+ *
76
+ * `heading` — `null` on the zeroth element (the preamble before the first heading). It
77
+ * is ALWAYS there, including empty: the former `split` also always returned the chunk
78
+ * before the first separator as its zeroth element, and callers rely on that
79
+ * (`sub === chunk` in `artifact-coverage` meant "there are no subsections").
80
+ *
81
+ * `raw` — WITH the heading line (it is used to count `§` references and bold numbers,
82
+ * which occur in the heading itself too), `body` — without it (it is used to count words).
83
+ *
84
+ * 2026-08-11: moved here rather than copied into every script, because the chunk
85
+ * boundary is the one place where an off-by-one is easy, and such a mistake has already
86
+ * happened (`recordBlock` in `skill-corpus.mjs` returned a single "#" character for all
87
+ * 21 skills).
88
+ */
89
+ export declare function splitSections(text: string, { min, max }?: {
90
+ min?: number;
91
+ max?: number;
92
+ }): Section[];
93
+ /**
94
+ * The text without the contents of ```-blocks (the fence lines themselves go too).
95
+ *
96
+ * Through the parser, not `/```[\s\S]*?```/g`: that pattern glues the end of one block
97
+ * to the start of the next when the number of fences is odd, knows nothing about `~~~`
98
+ * fences or indented fences, and silently eats the prose between blocks.
99
+ *
100
+ * `blank: true` — the block's lines are NOT deleted but REPLACED with empty ones. The
101
+ * difference is not cosmetic: deleting the lines GLUES the paragraph before the block to
102
+ * the paragraph after it, and a code block is a block boundary — on the other side a
103
+ * different paragraph starts. Measured 2026-08-11 on `<papers-root>/<paper>/README.md`:
104
+ * `prose-lint` counted 82 sentences there, and after the lines were deleted it counted
105
+ * 81 — the lead paragraph "**Reproduction commands:**" merged with the text AFTER the
106
+ * block into one sentence. That is exactly the failure against which `prose-lint` itself
107
+ * says "Paragraph and heading boundaries END a sentence", and it inflates the
108
+ * claims-per-sentence counter — the threshold at which the file emits findings. The
109
+ * former regex preserved the boundary (it left one newline on each side), so `blank` is
110
+ * also a preservation of the former behaviour where that behaviour was right.
111
+ */
112
+ /**
113
+ * The CONTENTS of fenced blocks — the other side of `stripFences`.
114
+ *
115
+ * Added 2026-09-08 for the check "a path as a command argument inside a ```-block"
116
+ * (the sixth form of a reference). A private regex for the fence there would have been
117
+ * the seventh instance of the class this knowledge base has already paid for:
118
+ * `/^```[\s\S]*?^```/gm` knows nothing about nested fences or about `~~~`, and the
119
+ * parser does — the `fence` token has a `content`.
120
+ *
121
+ * No parser — returns an empty list, and the caller must survive that: for hooks
122
+ * degradation is acceptable (see the module comment), while a silent fallback to a
123
+ * regex would mean a working degraded version that nobody notices.
124
+ */
125
+ export declare function fences(text: string): string[];
126
+ export declare function stripFences(text: string, { blank }?: {
127
+ blank?: boolean;
128
+ }): string;
129
+ /**
130
+ * For SCRIPTS, not for hooks: fails if there is no parser.
131
+ *
132
+ * For a linter degradation is acceptable — it is advisory and can say so out loud. A
133
+ * skill script hands numbers to a pipeline gate, and an empty list of headings there is
134
+ * indistinguishable from "the paper has no sections". A confident zero has already been
135
+ * read as a finding four times in this repo; here it is inexpressible.
136
+ */
137
+ export declare function requireMarkdown({ from, }?: {
138
+ from?: string;
139
+ }): void;
140
+ /**
141
+ * GFM tables — rows, cells and the line range, WITH THE PARSER.
142
+ *
143
+ * The only consumer as of 2026-08-20 is `crosspost-article`, which needs to re-lay a
144
+ * table into a monospace block for a platform without tables (Medium). It lives here
145
+ * and not in the skill, by the rule "markup is parsed with a parser, and in one place":
146
+ * with a regex a table is told apart from a line of text with pipes only by its
147
+ * neighbours, and that is exactly the class that has already cost this repo 27 places.
148
+ *
149
+ * Returns `{ line, endLine, rows }`, where `rows[0]` is the header; the alignment row
150
+ * (`| --- |`) is thrown away, because in monospace output it has nothing to express.
151
+ */
152
+ /**
153
+ * The document's paragraphs — `paragraph_open` line ranges, WITH THE PARSER.
154
+ * `[{ line, endLine }]`.
155
+ *
156
+ * The only consumer as of 2026-08-21 is `crosspost-article`: the blog's sources are
157
+ * hard-wrapped at a column (an editorial habit, not markdown), and the platforms render
158
+ * a single `\n` inside a paragraph DIFFERENTLY — dev.to (Redcarpet) keeps it as a
159
+ * literal line break, and the paragraph arrives torn into short lines exactly at the
160
+ * source file's boundaries. Medium has no such defect not because the platform is more
161
+ * honest, but because the paste goes through "Import a story" — the importer takes the
162
+ * ALREADY RENDERED page of the site (where the breaks were collapsed by the browser long
163
+ * ago), not the raw markdown.
164
+ *
165
+ * The range is EXACTLY the one `t.map` gives on `paragraph_open` — that is, a code
166
+ * fence, a heading, a table, a list (in a TIGHT list the item is not wrapped in a
167
+ * `paragraph_open` at all, it has no paragraph of its own) fall outside this function
168
+ * automatically, by the construction of the parser, and not by a separate line-type
169
+ * check.
170
+ */
171
+ export declare function paragraphs(text: string): {
172
+ line: number;
173
+ endLine: number;
174
+ }[];
175
+ export declare function tables(text: string): {
176
+ line: number;
177
+ endLine: number;
178
+ rows: string[][];
179
+ }[];
180
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../lib/markdown.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,iGAAiG;AACjG,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,0GAA0G;AAC1G,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,sFAAsF;AACtF,MAAM,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,KAAK,EAAE,CAAC;AAUvD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,eAAoB,CAAC;AAgB9C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGrD;AASD;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,EAAE,KAAsB,EAAE,GAAE;IAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAA;CAAO,GACxD,OAAO,EAAE,CAmBX;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,EAAE,GAAO,EAAE,GAAO,EAAE,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GACxD,OAAO,EAAE,CAsBX;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAM7C;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,EAAE,KAAa,EAAE,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAC1C,MAAM,CAUR;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAsB,GACvB,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,IAAI,CAmB/B;AAED;;;;;;;;;;;GAWG;AACH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAS5E;AAED,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,EAAE,CAoBvD"}
@@ -0,0 +1,302 @@
1
+ let md = null;
2
+ try {
3
+ const { default: MarkdownIt } = await import("markdown-it");
4
+ md = new MarkdownIt();
5
+ }
6
+ catch {
7
+ md = null;
8
+ }
9
+ /**
10
+ * Whether the parser resolved. A linter must check this ITSELF and say out loud that
11
+ * its heading checks are off: with no parser `headings()` returns an empty list, and
12
+ * silent emptiness reads as "the document has no headings", that is, as a clean
13
+ * document. The nudge lives in the linters, because by contract (see the header) this
14
+ * file has no right to produce a single finding.
15
+ */
16
+ export const MD_AVAILABLE = () => md !== null;
17
+ /** markdown-it's block tokens for `text`, or null when it did not resolve. A test passes its own. */
18
+ const defaultParse = () => {
19
+ const parser = md;
20
+ return parser === null ? null : (text) => parser.parse(text, {});
21
+ };
22
+ /**
23
+ * The frontmatter is BLANKED with spaces, not cut out: the offsets must stay the
24
+ * same, because the checks cut the document by offset. Blanking is necessary — inside
25
+ * a YAML block scalar a line indented by two spaces (` ## Foo`) is a real ATX
26
+ * heading to CommonMark, and without blanking the frontmatter starts supplying
27
+ * sections.
28
+ */
29
+ const FRONTMATTER_RE = /^---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?=\r?\n|$)/;
30
+ export function blankFrontmatter(text) {
31
+ const m = FRONTMATTER_RE.exec(text);
32
+ return m ? m[0].replace(/[^\n]/g, " ") + text.slice(m[0].length) : text;
33
+ }
34
+ /**
35
+ * The frontmatter body (between the fences), or `null` — if the file opens without one.
36
+ *
37
+ * Added 2026-08-20, when eight places in `.claude/**` cut the frontmatter with eight
38
+ * slightly different regexes: some knew about `\r\n`, some did not; some required a
39
+ * newline after the closing fence, some did not. The difference between them is not
40
+ * style, it is a different answer on one and the same file.
41
+ *
42
+ * ⚠️ This is NOT a parser and does not claim to be: `---` frontmatter is not markdown,
43
+ * no markdown parser models it (the analysis is in the root `CLAUDE.md`, "Considered
44
+ * and rejected: gray-matter"). The value here is one fence instead of eight, and the
45
+ * parsing of VALUES is done by `js-yaml` at the caller.
46
+ */
47
+ export function frontmatterBlock(text) {
48
+ const m = FRONTMATTER_RE.exec(text);
49
+ if (!m)
50
+ return null;
51
+ const inner = m[0]
52
+ .replace(/^---[ \t]*\r?\n/, "")
53
+ .replace(/\r?\n---[ \t]*$/, "");
54
+ return inner;
55
+ }
56
+ /**
57
+ * The document WITHOUT the frontmatter — the block is cut out together with the
58
+ * newline after it.
59
+ *
60
+ * Differs from {@link blankFrontmatter} in that the offsets SHIFT. Both forms are
61
+ * needed and both have been used already: blanking — where character positions are
62
+ * later shown to the user; cutting — where the text is merely counted. Choose by what
63
+ * the caller does, not by taste.
64
+ */
65
+ export function stripFrontmatter(text) {
66
+ const m = FRONTMATTER_RE.exec(text);
67
+ return m ? text.slice(m[0].length).replace(/^\r?\n/, "") : text;
68
+ }
69
+ /** Line-start offsets — so that `token.map` becomes a position in the source string. */
70
+ function lineStarts(text) {
71
+ const out = [0];
72
+ for (let i = 0; i < text.length; i++)
73
+ if (text[i] === "\n")
74
+ out.push(i + 1);
75
+ return out;
76
+ }
77
+ /**
78
+ * All the document's headings: `[{ depth, text, line, offset }]`, in order of occurrence.
79
+ *
80
+ * `offset` — the index of the start of the heading's line IN THE SAME text that was
81
+ * passed in, in `slice`/`indexOf` units (UTF-16), because those are exactly what the
82
+ * checks cut the document with. `line` — 0-based line number. `text` — without the
83
+ * hashes, trimmed at the edges.
84
+ *
85
+ * ⚠️ ATX ONLY (`## Heading`). Setext (`Heading\n---`) is deliberately NOT counted as a
86
+ * heading: in this knowledge base `---` is a prose separator, and a paragraph it stands
87
+ * under without a blank line would become a level-2 heading per CommonMark. The former
88
+ * regexps knew only ATX, so this preserves the contract rather than narrowing it.
89
+ */
90
+ export function headings(text, { parse = defaultParse() } = {}) {
91
+ if (parse === null)
92
+ return [];
93
+ const toks = parse(blankFrontmatter(text));
94
+ const starts = lineStarts(text);
95
+ const out = [];
96
+ for (const [i, t] of toks.entries()) {
97
+ if (t.type !== "heading_open" || !t.map)
98
+ continue;
99
+ if (!t.markup || !t.markup.startsWith("#"))
100
+ continue; // setext — see the caveat above
101
+ // markdown-it follows `heading_open` with its `inline` token and maps blocks to lines of the
102
+ // parsed text; the fallbacks are for a token stream that does not (another parser version).
103
+ const inline = toks[i + 1];
104
+ out.push({
105
+ depth: Number(t.tag.slice(1)),
106
+ text: inline?.type === "inline" ? inline.content.trim() : "",
107
+ line: t.map[0],
108
+ offset: starts[t.map[0]] ?? 0,
109
+ });
110
+ }
111
+ return out;
112
+ }
113
+ /**
114
+ * Slicing the document into chunks "a heading + everything up to the next heading FROM
115
+ * THE SAME RANGE of levels". → `[{ heading, raw, body }]`.
116
+ *
117
+ * This is exactly what four scripts did as `split(/^(?=## )/m)` and
118
+ * `split(/^(?=#{2,3} )/m)`. The shape of the expression lied about the intent: "two or
119
+ * three hashes" is about CHARACTERS, while what is needed is the LEVEL, and `#{2,3}`
120
+ * also caught a hash inside a ```-block, that is, it cut a quotation from someone
121
+ * else's paper as a section of its own.
122
+ *
123
+ * `heading` — `null` on the zeroth element (the preamble before the first heading). It
124
+ * is ALWAYS there, including empty: the former `split` also always returned the chunk
125
+ * before the first separator as its zeroth element, and callers rely on that
126
+ * (`sub === chunk` in `artifact-coverage` meant "there are no subsections").
127
+ *
128
+ * `raw` — WITH the heading line (it is used to count `§` references and bold numbers,
129
+ * which occur in the heading itself too), `body` — without it (it is used to count words).
130
+ *
131
+ * 2026-08-11: moved here rather than copied into every script, because the chunk
132
+ * boundary is the one place where an off-by-one is easy, and such a mistake has already
133
+ * happened (`recordBlock` in `skill-corpus.mjs` returned a single "#" character for all
134
+ * 21 skills).
135
+ */
136
+ export function splitSections(text, { min = 2, max = 6 } = {}) {
137
+ const hs = headings(text).filter((h) => h.depth >= min && h.depth <= max);
138
+ const out = [];
139
+ const [first] = hs;
140
+ const preEnd = first ? first.offset : text.length;
141
+ out.push({
142
+ heading: null,
143
+ raw: text.slice(0, preEnd),
144
+ body: text.slice(0, preEnd),
145
+ });
146
+ for (const [i, h] of hs.entries()) {
147
+ const next = hs[i + 1];
148
+ const end = next ? next.offset : text.length;
149
+ const nl = text.indexOf("\n", h.offset);
150
+ const bodyStart = nl === -1 || nl + 1 > end ? end : nl + 1;
151
+ out.push({
152
+ heading: h,
153
+ raw: text.slice(h.offset, end),
154
+ body: text.slice(bodyStart, end),
155
+ });
156
+ }
157
+ return out;
158
+ }
159
+ /**
160
+ * The text without the contents of ```-blocks (the fence lines themselves go too).
161
+ *
162
+ * Through the parser, not `/```[\s\S]*?```/g`: that pattern glues the end of one block
163
+ * to the start of the next when the number of fences is odd, knows nothing about `~~~`
164
+ * fences or indented fences, and silently eats the prose between blocks.
165
+ *
166
+ * `blank: true` — the block's lines are NOT deleted but REPLACED with empty ones. The
167
+ * difference is not cosmetic: deleting the lines GLUES the paragraph before the block to
168
+ * the paragraph after it, and a code block is a block boundary — on the other side a
169
+ * different paragraph starts. Measured 2026-08-11 on `<papers-root>/<paper>/README.md`:
170
+ * `prose-lint` counted 82 sentences there, and after the lines were deleted it counted
171
+ * 81 — the lead paragraph "**Reproduction commands:**" merged with the text AFTER the
172
+ * block into one sentence. That is exactly the failure against which `prose-lint` itself
173
+ * says "Paragraph and heading boundaries END a sentence", and it inflates the
174
+ * claims-per-sentence counter — the threshold at which the file emits findings. The
175
+ * former regex preserved the boundary (it left one newline on each side), so `blank` is
176
+ * also a preservation of the former behaviour where that behaviour was right.
177
+ */
178
+ /**
179
+ * The CONTENTS of fenced blocks — the other side of `stripFences`.
180
+ *
181
+ * Added 2026-09-08 for the check "a path as a command argument inside a ```-block"
182
+ * (the sixth form of a reference). A private regex for the fence there would have been
183
+ * the seventh instance of the class this knowledge base has already paid for:
184
+ * `/^```[\s\S]*?^```/gm` knows nothing about nested fences or about `~~~`, and the
185
+ * parser does — the `fence` token has a `content`.
186
+ *
187
+ * No parser — returns an empty list, and the caller must survive that: for hooks
188
+ * degradation is acceptable (see the module comment), while a silent fallback to a
189
+ * regex would mean a working degraded version that nobody notices.
190
+ */
191
+ export function fences(text) {
192
+ if (md === null)
193
+ return [];
194
+ const out = [];
195
+ for (const t of md.parse(blankFrontmatter(text), {}))
196
+ if (t.type === "fence" || t.type === "code_block")
197
+ out.push(t.content);
198
+ return out;
199
+ }
200
+ export function stripFences(text, { blank = false } = {}) {
201
+ if (md === null)
202
+ return text;
203
+ const lines = text.split("\n");
204
+ const drop = new Set();
205
+ for (const t of md.parse(blankFrontmatter(text), {}))
206
+ if ((t.type === "fence" || t.type === "code_block") && t.map)
207
+ for (let i = t.map[0]; i < t.map[1]; i++)
208
+ drop.add(i);
209
+ return blank
210
+ ? lines.map((l, i) => (drop.has(i) ? "" : l)).join("\n")
211
+ : lines.filter((_, i) => !drop.has(i)).join("\n");
212
+ }
213
+ /**
214
+ * For SCRIPTS, not for hooks: fails if there is no parser.
215
+ *
216
+ * For a linter degradation is acceptable — it is advisory and can say so out loud. A
217
+ * skill script hands numbers to a pipeline gate, and an empty list of headings there is
218
+ * indistinguishable from "the paper has no sections". A confident zero has already been
219
+ * read as a finding four times in this repo; here it is inexpressible.
220
+ */
221
+ export function requireMarkdown({ from = import.meta.url, } = {}) {
222
+ if (MD_AVAILABLE())
223
+ return;
224
+ // 🔴 THE CURE DEPENDS ON WHERE THIS COPY RUNS FROM. Measured 2026-09-19: a Claude Code plugin
225
+ // copy is installed without dependencies (`npm pack` strips `package-lock.json`, and the plugin
226
+ // cache runs `npm ci` only with a lockfile). The plugin channel was removed in #82, but a copy
227
+ // installed before then still runs from there, and "npm i at the repo root" would point its user
228
+ // at a repository they do not have. The location is readable from this file's own URL (`from`,
229
+ // a parameter only so a test can name a plugin-cache location without copying the file there).
230
+ const fromPluginCache = from.includes("/.claude/plugins/");
231
+ console.error("markdown-it does not resolve — this script parses markup with a parser and without it " +
232
+ "would produce a confident zero instead of an error.\n" +
233
+ (fromPluginCache
234
+ ? " Running from a PLUGIN copy, which is installed without dependencies. Install the npm\n" +
235
+ " package in the project as well (`npm i paperlint`) and call it through\n" +
236
+ " `npx paperlint`, which resolves from the project's own tree."
237
+ : " Cured by `npm i` at the repo root."));
238
+ process.exit(2);
239
+ }
240
+ /**
241
+ * GFM tables — rows, cells and the line range, WITH THE PARSER.
242
+ *
243
+ * The only consumer as of 2026-08-20 is `crosspost-article`, which needs to re-lay a
244
+ * table into a monospace block for a platform without tables (Medium). It lives here
245
+ * and not in the skill, by the rule "markup is parsed with a parser, and in one place":
246
+ * with a regex a table is told apart from a line of text with pipes only by its
247
+ * neighbours, and that is exactly the class that has already cost this repo 27 places.
248
+ *
249
+ * Returns `{ line, endLine, rows }`, where `rows[0]` is the header; the alignment row
250
+ * (`| --- |`) is thrown away, because in monospace output it has nothing to express.
251
+ */
252
+ /**
253
+ * The document's paragraphs — `paragraph_open` line ranges, WITH THE PARSER.
254
+ * `[{ line, endLine }]`.
255
+ *
256
+ * The only consumer as of 2026-08-21 is `crosspost-article`: the blog's sources are
257
+ * hard-wrapped at a column (an editorial habit, not markdown), and the platforms render
258
+ * a single `\n` inside a paragraph DIFFERENTLY — dev.to (Redcarpet) keeps it as a
259
+ * literal line break, and the paragraph arrives torn into short lines exactly at the
260
+ * source file's boundaries. Medium has no such defect not because the platform is more
261
+ * honest, but because the paste goes through "Import a story" — the importer takes the
262
+ * ALREADY RENDERED page of the site (where the breaks were collapsed by the browser long
263
+ * ago), not the raw markdown.
264
+ *
265
+ * The range is EXACTLY the one `t.map` gives on `paragraph_open` — that is, a code
266
+ * fence, a heading, a table, a list (in a TIGHT list the item is not wrapped in a
267
+ * `paragraph_open` at all, it has no paragraph of its own) fall outside this function
268
+ * automatically, by the construction of the parser, and not by a separate line-type
269
+ * check.
270
+ */
271
+ export function paragraphs(text) {
272
+ if (md === null)
273
+ return [];
274
+ return md
275
+ .parse(blankFrontmatter(text), {})
276
+ .flatMap((t) => t.type === "paragraph_open" && t.map
277
+ ? [{ line: t.map[0], endLine: t.map[1] }]
278
+ : []);
279
+ }
280
+ export function tables(text) {
281
+ if (md === null)
282
+ return [];
283
+ const lines = blankFrontmatter(text).split("\n");
284
+ const out = [];
285
+ for (const t of md.parse(blankFrontmatter(text), {})) {
286
+ if (t.type !== "table_open" || !t.map)
287
+ continue;
288
+ const rows = [];
289
+ for (const raw of lines.slice(t.map[0], t.map[1])) {
290
+ if (/^\s*\|?[\s:|-]+\|?\s*$/.test(raw) && raw.includes("-"))
291
+ continue; // alignment
292
+ rows.push(raw
293
+ .replace(/^\s*\|/, "")
294
+ .replace(/\|\s*$/, "")
295
+ .split("|")
296
+ .map((c) => c.trim()));
297
+ }
298
+ out.push({ line: t.map[0], endLine: t.map[1], rows });
299
+ }
300
+ return out;
301
+ }
302
+ //# sourceMappingURL=markdown.js.map