paperlint 19.0.2 → 19.0.3

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 (88) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CLAUDE.md +2 -2
  3. package/dist/CLAUDE.md.spec.d.ts.map +1 -1
  4. package/dist/CLAUDE.md.spec.js +7 -1
  5. package/dist/CLAUDE.md.spec.js.map +1 -1
  6. package/dist/cli.d.ts +2 -21
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +45 -93
  9. package/dist/cli.js.map +1 -1
  10. package/dist/doctor.d.ts +8 -10
  11. package/dist/doctor.d.ts.map +1 -1
  12. package/dist/doctor.js +27 -37
  13. package/dist/doctor.js.map +1 -1
  14. package/dist/hooks-notice.d.ts +8 -2
  15. package/dist/hooks-notice.d.ts.map +1 -1
  16. package/dist/hooks-notice.js +15 -20
  17. package/dist/hooks-notice.js.map +1 -1
  18. package/dist/hooks-settings.d.ts +1 -1
  19. package/dist/hooks-settings.js +1 -1
  20. package/dist/init.d.ts +1 -1
  21. package/dist/init.js +5 -5
  22. package/dist/lib/paper-config.d.ts +4 -9
  23. package/dist/lib/paper-config.d.ts.map +1 -1
  24. package/dist/lib/paper-config.js +4 -9
  25. package/dist/lib/paper-config.js.map +1 -1
  26. package/dist/papers-roots.d.ts +19 -0
  27. package/dist/papers-roots.d.ts.map +1 -0
  28. package/dist/papers-roots.js +42 -0
  29. package/dist/papers-roots.js.map +1 -0
  30. package/dist/retired-hooks.d.ts +6 -0
  31. package/dist/retired-hooks.d.ts.map +1 -0
  32. package/dist/retired-hooks.js +34 -0
  33. package/dist/retired-hooks.js.map +1 -0
  34. package/dist/skill-chunks/chunk-C2G5EK7S.js +579 -0
  35. package/dist/skill-chunks/{chunk-UL4INX2P.js → chunk-L3NJUJUP.js} +446 -446
  36. package/dist/skill-chunks/{chunk-EOVEVX67.js → chunk-X4VKG4KT.js} +1 -1
  37. package/dist/types.d.ts +1 -1
  38. package/docs/install.md +9 -11
  39. package/docs/layout.md +2 -4
  40. package/docs/rules/paper/allowed-files-only.md +1 -2
  41. package/docs/testing.md +1 -1
  42. package/eslint.config.mjs +1 -1
  43. package/lib/paper-config.harness.mjs +3 -6
  44. package/lib/paper-config.ts +4 -9
  45. package/package.json +2 -3
  46. package/plugin/hooks/hooks.json +0 -13
  47. package/scripts/coverage-config.test.ts +0 -1
  48. package/scripts/eslint-file-length.mjs +0 -1
  49. package/skills/argument-arc/scripts/headings.js +2 -2
  50. package/skills/build-label-page/scripts/label-page.js +125 -125
  51. package/skills/cold-read-diff/scripts/cold-read.js +11 -11
  52. package/skills/paper-pipeline/scripts/extract-ref-facts.js +3 -3
  53. package/skills/paper-status/SKILL.md +1 -2
  54. package/skills/paper-status/SKILL.md.spec.ts +0 -1
  55. package/skills/pc-panel-review/scripts/prior-reviews.js +1 -1
  56. package/skills/verify-citations/scripts/bib-authors.js +3 -3
  57. package/skills/verify-citations/scripts/verify-cites.js +3 -3
  58. package/src/CLAUDE.md +16 -1
  59. package/src/CLAUDE.md.spec.ts +12 -1
  60. package/src/cli.harness.mjs +14 -79
  61. package/src/cli.test.ts +4 -34
  62. package/src/cli.ts +47 -140
  63. package/src/doctor.harness.mjs +17 -59
  64. package/src/doctor.test.ts +1 -1
  65. package/src/doctor.ts +26 -41
  66. package/src/domain/paper-folder.test.ts +1 -1
  67. package/src/hooks-notice.test.ts +21 -74
  68. package/src/hooks-notice.ts +30 -20
  69. package/src/hooks-settings.harness.ts +25 -27
  70. package/src/hooks-settings.ts +1 -1
  71. package/src/in-process-hooks.test.ts +18 -0
  72. package/src/init.ts +5 -5
  73. package/src/lint-edited-site-example.test.ts +0 -3
  74. package/src/papers-roots.test.ts +56 -0
  75. package/src/papers-roots.ts +56 -0
  76. package/src/retired-hooks.test.ts +155 -0
  77. package/src/retired-hooks.ts +41 -0
  78. package/src/types.ts +1 -1
  79. package/dist/skill-chunks/chunk-GRSXIWYF.js +0 -352
  80. package/hooks/CLAUDE.md +0 -34
  81. package/hooks/CLAUDE.md.spec.ts +0 -30
  82. package/hooks/hooks.harness.ts +0 -566
  83. package/hooks/paper-edit-guard.hook.d.mts +0 -12
  84. package/hooks/paper-edit-guard.hook.mjs +0 -443
  85. package/hooks/paper-edit-guard.test.ts +0 -66
  86. package/hooks/paper-skills-nudge.hook.d.mts +0 -22
  87. package/hooks/paper-skills-nudge.hook.mjs +0 -193
  88. package/hooks/paper-skills-nudge.test.ts +0 -122
package/src/cli.ts CHANGED
@@ -32,9 +32,7 @@ import {
32
32
  statSync,
33
33
  } from "node:fs";
34
34
  import { absolutePath } from "./domain/paths.ts";
35
- import { createRequire } from "node:module";
36
35
  import { stripVTControlCharacters } from "node:util";
37
- import { spawnSync } from "node:child_process";
38
36
  import { fileURLToPath } from "node:url";
39
37
  import { join, dirname, resolve, relative, basename, sep } from "node:path";
40
38
  import markdown from "@eslint/markdown";
@@ -188,7 +186,6 @@ import {
188
186
  // and from dist/ — see CONTRIBUTING.md.
189
187
  import {
190
188
  CONFIG_FILE,
191
- DEFAULT_PAPERS_ROOT,
192
189
  PAPERS_DIR_FIELD,
193
190
  PAPER_ONLY_KEYS,
194
191
  SETTINGS_KEYS,
@@ -240,6 +237,7 @@ import {
240
237
  folderLayoutRules,
241
238
  } from "./folder-layout-rule.ts";
242
239
  import { folderLayoutHook } from "./folder-layout-hook.ts";
240
+ import { papersDirOf, papersRoots, toPaths } from "./papers-roots.ts";
243
241
  import { paperFolderOf, writtenPath } from "./domain/paper-folder.ts";
244
242
  import { papersReached, type PaperTree } from "./domain/paper-dirs.ts";
245
243
  import {
@@ -253,6 +251,7 @@ import {
253
251
  hookNotRunningText,
254
252
  } from "./hooks-notice.ts";
255
253
  import { unwiredHooks } from "./hooks-settings.ts";
254
+ import { RETIRED_HOOKS, retiredWired } from "./retired-hooks.ts";
256
255
  import {
257
256
  linkSkills,
258
257
  locatePackage,
@@ -1427,34 +1426,11 @@ export function readConfig(
1427
1426
  return { opts: settings.value, configPath, root };
1428
1427
  }
1429
1428
 
1430
- /** The papers directory field of the settings, read by its one declared name; the default when absent. */
1431
- export function papersDirOf(opts: PaperlintConfig): unknown {
1432
- const declared = opts.papersDir;
1433
- return declared === undefined ? DEFAULT_PAPERS_ROOT : declared;
1434
- }
1435
-
1436
1429
  /** The error for a papers directory that is missing or holds no paper. */
1437
1430
  export const noPapersMessage = (dir: string): string =>
1438
1431
  `no papers in ${dir}/ — create one with \`npx paperlint new <name>\`, or set "${PAPERS_DIR_FIELD}" ` +
1439
1432
  `in ${CONFIG_FILE} if your papers live elsewhere`;
1440
1433
 
1441
- /** The papers directories of a read config, absolute: each relative to the project root. */
1442
- export const papersRoots = (cfg: {
1443
- opts: PaperlintConfig;
1444
- root: string;
1445
- }): string[] =>
1446
- toPaths(papersDirOf(cfg.opts)).map((rel) => resolve(cfg.root, rel));
1447
-
1448
- /** The papers directory may be one directory or several; both spellings normalise to a list. */
1449
- export function toPaths(papers: unknown): string[] {
1450
- if (typeof papers === "string") return papers.trim() ? [papers.trim()] : [];
1451
- if (Array.isArray(papers))
1452
- return papers.filter(
1453
- (x): x is string => typeof x === "string" && x.trim() !== "",
1454
- );
1455
- return [];
1456
- }
1457
-
1458
1434
  /** What an in-process hook is handed: the payload, and where its output and complaints go. */
1459
1435
  interface HookIo {
1460
1436
  readonly err: typeof console.error;
@@ -1464,8 +1440,16 @@ interface HookIo {
1464
1440
 
1465
1441
  /**
1466
1442
  * Hooks that run inside this process instead of as a vigiles program, each because it must call the
1467
- * package's own code (`src/folder-layout-hook.ts` says why for its one). Advisory: whatever goes
1468
- * wrong, the tool call has already happened, so it says so on stderr and exits 0.
1443
+ * package's own code (`src/folder-layout-hook.ts` says why for its one). Each exits 0; a gate
1444
+ * refuses through its JSON, and an advisory hook that fails says so on stderr.
1445
+ *
1446
+ * TODO(zernie/vigiles#472, zernie/paperlint#650): this table is a workaround, not a pattern. It
1447
+ * exists because a vigiles hook program may import only `vigiles/hook`, so a hook that needs this
1448
+ * package's code was routed around the runtime: it gets no capability check, no state and no
1449
+ * throttle, and the package ends up with two ways to run a hook. Do NOT add an entry and do not
1450
+ * grow one. A hook that needs the package's code waits for vigiles#472 (a hook may declare a module
1451
+ * of its own package); then every entry here moves to `hooks/<name>.hook.mjs` and the table is
1452
+ * deleted (#650). `src/in-process-hooks.test.ts` fails when a name is added.
1469
1453
  */
1470
1454
  const IN_PROCESS_HOOKS: Readonly<
1471
1455
  Record<string, (io: HookIo) => number | Promise<number>>
@@ -1515,6 +1499,10 @@ const IN_PROCESS_HOOKS: Readonly<
1515
1499
  },
1516
1500
  };
1517
1501
 
1502
+ /** The names in `IN_PROCESS_HOOKS`, for the test that keeps the list from growing. */
1503
+ export const IN_PROCESS_HOOK_NAMES: readonly string[] =
1504
+ Object.keys(IN_PROCESS_HOOKS);
1505
+
1518
1506
  /**
1519
1507
  * The words after `submission` read by this CLI's own parser, as the command reads them: the paper
1520
1508
  * and `--pdf` a send names, null for their defaults — or null when the words would not run cleanly
@@ -1634,18 +1622,6 @@ const firstLine = (message: string): string => message.split("\n", 1).join("");
1634
1622
  /** What `runHook` takes; every effect is injectable, so a test stages none of them. */
1635
1623
  interface HookOptions {
1636
1624
  readonly err?: typeof console.error;
1637
- /** Runs the hook with the terminal's streams: `spawnSync` is one. Only its status and stdout are read. */
1638
- readonly run?: (
1639
- file: string,
1640
- args: readonly string[],
1641
- options: {
1642
- readonly stdio:
1643
- "inherit" | readonly ["pipe", "pipe" | "inherit", "inherit"];
1644
- readonly input?: string;
1645
- readonly encoding?: "utf8";
1646
- },
1647
- ) => { readonly status: number | null; readonly stdout?: string | null };
1648
- readonly resolve?: (spec: string) => string;
1649
1625
  /** The hook's payload, as Claude Code sends it on stdin. */
1650
1626
  readonly stdin?: () => string;
1651
1627
  /** Where an in-process hook's output goes: stdout, which Claude Code reads. */
@@ -1668,22 +1644,6 @@ const defaultOut = (text: string): void => {
1668
1644
  process.stdout.write(text);
1669
1645
  };
1670
1646
 
1671
- /** The real spawner, narrowed to what `runHook` asks of it. */
1672
- export const spawnHook: NonNullable<HookOptions["run"]> = (file, args, o) => {
1673
- const r =
1674
- o.stdio === "inherit"
1675
- ? spawnSync(file, [...args], { stdio: "inherit" })
1676
- : spawnSync(file, [...args], {
1677
- stdio: [...o.stdio],
1678
- input: o.input,
1679
- encoding: "utf8",
1680
- });
1681
- return {
1682
- status: r.status,
1683
- stdout: typeof r.stdout === "string" ? r.stdout : null,
1684
- };
1685
- };
1686
-
1687
1647
  /** The project root the hooks are anchored to. */
1688
1648
  const hookRoot = (io: HookOptions): string =>
1689
1649
  io.projectDir ?? process.env["CLAUDE_PROJECT_DIR"] ?? process.cwd();
@@ -1710,11 +1670,13 @@ function owed(
1710
1670
  readonly missing: readonly string[];
1711
1671
  readonly byHand: boolean;
1712
1672
  readonly skills: readonly string[];
1673
+ readonly retired: readonly string[];
1713
1674
  } {
1714
1675
  if (installedPluginVersion(claude.plugin(absolutePath(root))) !== null)
1715
- return { missing: [], byHand: false, skills: [] };
1676
+ return { missing: [], byHand: false, skills: [], retired: [] };
1716
1677
  const { missing, byHand } = unwiredHooks(root);
1717
- return { missing, byHand, skills: unlinkedSkills(skillLinks(root)) };
1678
+ const skills = unlinkedSkills(skillLinks(root));
1679
+ return { missing, byHand, skills, retired: retiredWired(root) };
1718
1680
  }
1719
1681
 
1720
1682
  interface Pending {
@@ -1730,16 +1692,22 @@ interface Pending {
1730
1692
  function pendingNotice(io: ResolvedHookOptions): Pending | null {
1731
1693
  try {
1732
1694
  const root = hookRoot(io);
1733
- const { missing, byHand, skills } = owed(
1695
+ const { missing, byHand, skills, retired } = owed(
1734
1696
  root,
1735
1697
  io.skillLinks ?? readSkillLinks,
1736
1698
  io.claude ?? claudeCode(),
1737
1699
  );
1738
1700
  const version = io.version ?? packageVersion();
1739
- return (missing.length === 0 && skills.length === 0) ||
1701
+ return (missing.length === 0 &&
1702
+ skills.length === 0 &&
1703
+ retired.length === 0) ||
1740
1704
  !notYetTold(nodeFiles, root, version)
1741
1705
  ? null
1742
- : { text: noticeText(version, missing, byHand, skills), root, version };
1706
+ : {
1707
+ text: noticeText(version, missing, byHand, { skills, retired }),
1708
+ root,
1709
+ version,
1710
+ };
1743
1711
  } catch (e) {
1744
1712
  io.err(
1745
1713
  `paperlint: the unwired-hooks check did not run: ${firstLine(messageOf(e))}`,
@@ -1774,22 +1742,16 @@ function hooksLine(
1774
1742
  }
1775
1743
  }
1776
1744
 
1777
- const after = (
1778
- code: number | Promise<number>,
1779
- then: (code: number) => number,
1780
- ): number | Promise<number> =>
1781
- typeof code === "number" ? then(code) : code.then(then);
1782
-
1783
1745
  /**
1784
1746
  * The hook as always, with the notice added to what it printed — when its payload is about a paper's
1785
1747
  * file. The payload is read once and handed on; anything outside a paper, or unreadable, runs the hook
1786
1748
  * untouched and leaves the notice for the next edit that is about a paper.
1787
1749
  */
1788
- function runHookWithNotice(
1750
+ async function runHookWithNotice(
1789
1751
  name: string,
1790
1752
  notice: Pending,
1791
1753
  io: ResolvedHookOptions,
1792
- ): number | Promise<number> {
1754
+ ): Promise<number> {
1793
1755
  const text = ((): string | null => {
1794
1756
  try {
1795
1757
  return io.stdin();
@@ -1798,23 +1760,17 @@ function runHookWithNotice(
1798
1760
  }
1799
1761
  })();
1800
1762
  if (text === null) return runHookPlain(name, io);
1801
- const fed = { ...io, stdin: () => text, feed: text };
1763
+ const fed = { ...io, stdin: () => text };
1802
1764
  if (!touchesAPaper(text)) return runHookPlain(name, fed);
1803
1765
  const printed = collector();
1804
- return after(
1805
- runHookPlain(name, {
1806
- ...fed,
1807
- out: printed.write,
1808
- capture: true,
1809
- }),
1810
- (code) => {
1811
- const said = printed.text();
1812
- const merged = code === 0 ? mergeNotice(said, notice.text) : null;
1813
- // Remembered BEFORE it is said: a state that cannot be written must not make the notice repeat on every edit.
1814
- io.out(merged !== null && remember(notice, io) ? merged : said);
1815
- return code;
1816
- },
1817
- );
1766
+ // The one hook that carries the notice (NOTICE_HOOKS) always exits 0 (`lintEditedHook`), so Claude
1767
+ // Code reads what it printed, and the notice can ride on it.
1768
+ const code = await runHookPlain(name, { ...fed, out: printed.write });
1769
+ const said = printed.text();
1770
+ const merged = mergeNotice(said, notice.text);
1771
+ // Remembered BEFORE it is said: a state that cannot be written must not make the notice repeat on every edit.
1772
+ io.out(merged !== null && remember(notice, io) ? merged : said);
1773
+ return code;
1818
1774
  }
1819
1775
 
1820
1776
  /** Records that the notice was given; false, with one stderr line, when it cannot be. */
@@ -1832,64 +1788,15 @@ function remember(notice: Pending, io: ResolvedHookOptions): boolean {
1832
1788
 
1833
1789
  function runHookPlain(
1834
1790
  name: string | undefined,
1835
- {
1836
- err = console.error,
1837
- run = spawnHook,
1838
- // The resolver is injected so that "the runtime was not found" is checked by an assert and not
1839
- // by deleting node_modules: a failure must be reproducible, not staged.
1840
- // 🔴 WE RESOLVE THE PACKAGE, NOT A FILE INSIDE IT. `require.resolve("vigiles/dist/cli.js")`
1841
- // DOES NOT WORK: the package's `exports` map hands out only "." and nine named subpaths, and
1842
- // `./dist/cli.js` — even `./package.json` — is not among them:
1843
- // Package subpath './dist/cli.js' is not defined by "exports"
1844
- // This is neither our oversight nor their bug: a closed export map is normal practice. So we
1845
- // resolve the root entry ("." → dist/test.js), take its directory and put `cli.js` next to it —
1846
- // the very file the package itself declares as its `bin`.
1847
- resolve = (spec: string): string =>
1848
- createRequire(import.meta.url).resolve(spec),
1849
- stdin = defaultStdin,
1850
- out = defaultOut,
1851
- feed,
1852
- capture = false,
1853
- }: HookOptions & {
1854
- /** The payload already read from stdin, handed to a spawned hook on its stdin. */
1855
- readonly feed?: string;
1856
- /** Collect a spawned hook's stdout into `out` instead of letting it reach the terminal. */
1857
- readonly capture?: boolean;
1858
- } = {},
1791
+ { err, stdin, out }: ResolvedHookOptions,
1859
1792
  ): number | Promise<number> {
1860
1793
  const inProcess = IN_PROCESS_HOOKS[name ?? ""];
1861
1794
  if (inProcess !== undefined) return inProcess({ err, stdin, out });
1862
- const program = fileURLToPath(
1863
- new URL(`../hooks/${name ?? ""}.hook.mjs`, import.meta.url),
1864
- );
1865
- if (!name || !existsSync(program)) {
1866
- err(hookNotRunningText(name, program, packageVersion()));
1867
- return 1; // not 2: that denies every Bash command, the fix included (#324); not 0: nobody sees it
1868
- }
1869
- let runtime;
1870
- try {
1871
- runtime = join(dirname(resolve("vigiles")), "cli.js");
1872
- if (!existsSync(runtime))
1873
- throw new Error(`resolved vigiles, but no cli.js beside it: ${runtime}`);
1874
- } catch {
1875
- err(
1876
- `paperlint: the hook runtime (vigiles) is not resolvable from ${fileURLToPath(new URL(".", import.meta.url))}.\n` +
1877
- `The \`${name}\` hook is NOT running. Everything else — \`paperlint lint\`, CI — is unaffected.\n` +
1878
- `Reinstall this package so its dependencies are present.`,
1879
- );
1880
- return 1; // not 2: that would deny every Bash command; not 0: nobody would see this
1881
- }
1882
- const args = [runtime, "hook-runtime", "run-program", program];
1883
- const r =
1884
- feed === undefined
1885
- ? run(process.execPath, args, { stdio: "inherit" })
1886
- : run(process.execPath, args, {
1887
- stdio: ["pipe", capture ? "pipe" : "inherit", "inherit"],
1888
- input: feed,
1889
- encoding: "utf8",
1890
- });
1891
- if (capture && typeof r.stdout === "string") out(r.stdout);
1892
- return r.status ?? 0;
1795
+ // Removed on purpose, not mistyped: an entry `init` wrote before stays until `init` runs again, and
1796
+ // it fires on every tool call; `doctor` and the notice name it, so each call is silent.
1797
+ if (RETIRED_HOOKS.includes(name ?? "")) return 0;
1798
+ err(hookNotRunningText(name, packageVersion()));
1799
+ return 1; // not 2: that denies every Bash command, the fix included (#324); not 0: nobody sees it
1893
1800
  }
1894
1801
 
1895
1802
  /**
@@ -2735,7 +2642,7 @@ export async function run(
2735
2642
  // an explicable one.
2736
2643
  let results: ESLint.LintResult[];
2737
2644
  try {
2738
- results = await eslint.lintFiles(paths);
2645
+ results = await eslint.lintFiles([...paths]);
2739
2646
  } catch (e) {
2740
2647
  if (isEmptyLintSet(e)) results = [];
2741
2648
  else throw e;
@@ -3,7 +3,7 @@
3
3
  * file.
4
4
  *
5
5
  * 🔴 WHY A TEST MATTERS ESPECIALLY MUCH HERE. Doctor exists precisely because
6
- * `paper-edit-guard` cannot say "I am guarding nothing": silence is its success state. A broken
6
+ * a hook cannot say "I am watching nothing": silence is its success state. A broken
7
7
  * doctor has exactly the same property — it will print a cheerful list of checkmarks and never
8
8
  * notice a mismatch. That is, the check for a silent failure can itself fail silently, and only
9
9
  * this file can tell the two apart.
@@ -27,9 +27,6 @@ const HERE = dirname(fileURLToPath(import.meta.url));
27
27
  const { doctor, detectPapers, PROGRAMS, found } = await import(
28
28
  join(HERE, "doctor.ts")
29
29
  );
30
- const { papersRoot } = await import(
31
- join(HERE, "..", "hooks", "paper-edit-guard.hook.mjs")
32
- );
33
30
 
34
31
  const check = createChecker();
35
32
 
@@ -78,33 +75,24 @@ const runDoctor = (
78
75
  const r = runDoctor(dir, { cliPapers: "papers" });
79
76
  check("a consistent install — exit ZERO", r.code === 0);
80
77
  check(
81
- "and it says outright that the guarded directory is the linted one",
82
- /the same directory/.test(r.out),
78
+ "and it names the one directory that is linted",
79
+ /linted\s+papers$/m.test(r.out),
83
80
  );
84
81
  rmSync(dir, { recursive: true, force: true });
85
82
  }
86
83
 
87
- // ── II. THE VERY DEFECT: AN INSTALL FOLLOWING THE DOCS ─────────────────────────────────────
88
- // The CLI lints one directory and the hook guards another: the install that motivated doctor
89
- // (issue #33). Here the CLI was pointed elsewhere while the hook took the default.
84
+ // ── II. THE VERY DEFECT: THE PAPERS LIVE SOMEWHERE THE SETTINGS DO NOT NAME ─────────────────
85
+ // The install that motivated doctor (issue #33): nothing declared, so lint and the hooks both
86
+ // watch `papers/`, while the papers are in another directory.
90
87
  {
91
88
  const dir = consumer({ papersDir: "writing/drafts" });
92
- const r = runDoctor(dir, { cliPapers: "writing/drafts" });
89
+ const r = runDoctor(dir, { cliPapers: "papers" });
93
90
  check(
94
- "an install that follows the docs — a FAILURE, not a cheerful report",
91
+ "papers outside the declared directory — a FAILURE, not a cheerful report",
95
92
  r.code === 2,
96
93
  );
97
94
  check(
98
- "and BOTH directories are named, so the mismatch is visible rather than inferred",
99
- /will lint\s+writing\/drafts/.test(r.out) &&
100
- /will guard\s+papers/.test(r.out),
101
- );
102
- check(
103
- "🔴 and the CONSEQUENCE is stated: writes pass the guard unseen",
104
- /passes the guard unseen/.test(r.out),
105
- );
106
- check(
107
- "the directory that does not exist is named as a guard watching nothing",
95
+ "the directory that does not exist is named as watched by nothing",
108
96
  /watching nothing/.test(r.out),
109
97
  );
110
98
  check(
@@ -129,23 +117,23 @@ const runDoctor = (
129
117
  rmSync(dir, { recursive: true, force: true });
130
118
  }
131
119
 
132
- // ── II-quater. A paperlint.json THAT DOES NOT PARSE — the guard refuses every command ─────
120
+ // ── II-quater. A paperlint.json THAT DOES NOT PARSE — lint refuses to run ────────────────
133
121
  {
134
122
  const dir = consumer({ papersDir: "papers" });
135
123
  writeFileSync(join(dir, "paperlint.json"), '{ "papersDir": <<<<<<< HEAD\n');
136
124
  const r = runDoctor(dir, { cliPapers: "papers" });
137
125
  check("an unparsable paperlint.json — a FAILURE", r.code === 2);
138
126
  check(
139
- "named, with the way out (a file edit, not a command)",
127
+ "named, with what it blocks",
140
128
  /✗ paperlint\.json is not valid JSON/.test(r.out) &&
141
- /Edit or Write/.test(r.out),
129
+ /`paperlint lint` refuses to run/.test(r.out),
142
130
  );
143
131
  rmSync(dir, { recursive: true, force: true });
144
132
  }
145
133
 
146
134
  // ── II-ter. A FRESH PROJECT WITH NO PAPERS YET IS NOT BROKEN ───────────────────────────────
147
135
  // `init --yes` declares the default and creates no paper. The declared directory does not exist,
148
- // and no papers live anywhere else: the guard has nothing to protect yet. A warning with the next
136
+ // and no papers live anywhere else: there is nothing to check yet. A warning with the next
149
137
  // step, not a failure. (A missing directory while papers DO live elsewhere stays ✗ — case II.)
150
138
  {
151
139
  const dir = consumer({
@@ -164,43 +152,13 @@ const runDoctor = (
164
152
  rmSync(dir, { recursive: true, force: true });
165
153
  }
166
154
 
167
- // ── III. TWO DECLARATIONS HAVE DRIFTED APART ────────────────────────────────────────────────
168
- {
169
- const dir = consumer({ papersDir: "writing/drafts", declared: "papers" });
170
- mkdirSync(join(dir, "papers"), { recursive: true });
171
- const r = runDoctor(dir, { cliPapers: "writing/drafts" });
172
- check("both declarations exist, but differ — a FAILURE", r.code === 2);
173
- rmSync(dir, { recursive: true, force: true });
174
- }
175
-
176
- // ── IV. THE ROOT IS ASKED FOR FROM THE HOOK ITSELF, NOT RETOLD ─────────────────────────────
177
- // This is load-bearing: a copy of the logic would drift silently and print a confident wrong
178
- // answer.
179
- {
180
- const dir = consumer({ papersDir: "docs/papers", declared: "docs/papers/" });
181
- const r = runDoctor(dir, { cliPapers: "docs/papers" });
182
- const fromHook = papersRoot(
183
- JSON.stringify({ [PAPERS_DIR_FIELD]: "docs/papers/" }),
184
- );
185
- check("the hook itself trims the trailing slash", fromHook === "docs/papers");
186
- check(
187
- "and doctor prints EXACTLY what the hook returned, not its own reading",
188
- new RegExp(`will guard\\s+${fromHook}$`, "m").test(r.out),
189
- );
190
- check(
191
- "a trailing slash does not make the install look inconsistent",
192
- r.code === 0,
193
- );
194
- rmSync(dir, { recursive: true, force: true });
195
- }
196
-
197
- // ── V. THE HOOK'S REFUSAL IS PASSED ALONG, NOT TURNED INTO A DIRECTORY ─────────────────────
155
+ // ── V. A SETTING THAT NAMES NO DIRECTORY IS NAMED, NOT TURNED INTO ONE ─────────────────────
198
156
  {
199
157
  const dir = consumer({ papersDir: "papers", declared: "" });
200
- const r = runDoctor(dir, { cliPapers: "papers" });
158
+ const r = runDoctor(dir, { cliPapers: null });
201
159
  check(
202
- "an empty string in the declaration — the hook refuses, and doctor NAMES it",
203
- /the guard refuses/.test(r.out),
160
+ "an empty string in the declaration — doctor NAMES it as no directory",
161
+ /name no directory/.test(r.out),
204
162
  );
205
163
  rmSync(dir, { recursive: true, force: true });
206
164
  }
@@ -101,7 +101,7 @@ test("doctor exits 0 when every hook is wired once, or none is (--no-hooks is a
101
101
 
102
102
  test("doctor exits non-zero when the hooks are only partly wired", () => {
103
103
  assert.equal(exitWithHooks(allHooks.slice(1).map(hookCommand)), 2);
104
- assert.equal(exitWithHooks([hookCommand("paper-edit-guard")]), 2);
104
+ assert.equal(exitWithHooks([hookCommand("submission-confirm")]), 2);
105
105
  });
106
106
 
107
107
  /** Doctor's output for a project with one of init's hook commands and one present skill link. */
package/src/doctor.ts CHANGED
@@ -3,20 +3,18 @@
3
3
  *
4
4
  * 🔴 WHY THIS EXISTS AT ALL, when none of the eight tools surveyed for `docs/install.md` ships a
5
5
  * `doctor`. None of them needs one: a formatter that is misconfigured formats nothing and you see
6
- * it immediately. This package has `paper-edit-guard`, whose success state IS silence — it reports
7
- * nothing while guarding correctly and reports nothing while guarding a directory that does not
8
- * exist. From outside, "installed" and "protecting you" are the same picture.
6
+ * it immediately. This package has hooks whose success state IS silence: a hook watching the right
7
+ * directory and one watching a directory that does not exist both print nothing. From outside,
8
+ * "installed" and "working" are the same picture.
9
9
  *
10
10
  * Measured 2026-09-18, and this is the failure the command was written for: a consumer who follows
11
- * the documented install exactly — `paperlint init`, then point the config at their papers — gets a guard
12
- * that allows every Bash write to their paper sources. It only appears to work when the directory
11
+ * the documented install exactly — `paperlint init`, then point the config at their papers — gets hooks
12
+ * that watch the wrong directory. It only appears to work when the directory
13
13
  * path happens to contain the segment `papers`, because that is the default the hook falls back to.
14
14
  * (Issue #33.)
15
15
  *
16
- * 🔴 THE ROOT THE HOOK WOULD USE IS ASKED OF THE HOOK, NOT RE-DERIVED. `papersRoot` is imported
17
- * from `paper-edit-guard.hook.mjs` itself. A second implementation here would be a second source of
18
- * truth, which is the very defect this command reports — and it would drift silently, because a
19
- * copy that disagrees with the original still prints a confident answer.
16
+ * 🔴 THE CLI READS THE PAPERS DIRECTORY THROUGH ONE READER (`papersRoots`, src/papers-roots.ts); what
17
+ * doctor checks is that the directory exists, and that the papers do not live somewhere else.
20
18
  *
21
19
  * Prior art for the shape: `brew doctor`, `flutter doctor`, `npm doctor`, `expo-doctor`.
22
20
  */
@@ -25,17 +23,15 @@ import { type Dirent, existsSync, readFileSync, readdirSync } from "node:fs";
25
23
  import { join, relative, resolve } from "node:path";
26
24
  // eslint-disable-next-line boundaries/dependencies -- legacy I/O, moves behind a port in #76
27
25
  import { spawnSync } from "node:child_process";
28
- // Types come from `paper-edit-guard.hook.d.mts`; see the block above for why the import points at
29
- // the hook itself rather than at a shared module.
30
26
  import {
31
- papersRoot,
32
27
  DEFAULT_PAPERS_ROOT,
33
28
  PAPERS_DIR_FIELD,
34
29
  CONFIG_FILE,
35
- } from "../hooks/paper-edit-guard.hook.mjs";
30
+ } from "#lib/paper-config";
36
31
  import { PAPER_MARKERS } from "./build.ts";
37
32
  import { linkSkills, SKILLS_HOME, type LinkReport } from "./link-skills.ts";
38
33
  import { doctorHooks, initWiredHooks } from "./hooks-settings.ts";
34
+ import { retiredLines, retiredWired } from "./retired-hooks.ts";
39
35
  import { pluginLines } from "./doctor-plugin.ts";
40
36
  import { installedPluginVersion } from "./plugin-offer.ts";
41
37
  import type { PluginState } from "./ports/claude-code.ts";
@@ -167,7 +163,7 @@ export function detectPapers(
167
163
  /**
168
164
  * The root `paperlint.json`'s verdict. Absent, or silent on `papersDir`, is fine: the default is
169
165
  * `papers`, and the CLI and the hooks take it alike. Only a file that does not parse is a failure —
170
- * the edit guard refuses every Bash command while it cannot read it.
166
+ * `paperlint lint` refuses to run while it cannot read it.
171
167
  */
172
168
  function declarationVerdict(raw: string | null): {
173
169
  lines: string[];
@@ -187,7 +183,7 @@ function declarationVerdict(raw: string | null): {
187
183
  return {
188
184
  lines: [
189
185
  ` ✗ ${CONFIG_FILE} is not valid JSON: ${messageOf(e)}`,
190
- ` the edit guard refuses every Bash command until it parses — fix it with Edit or Write`,
186
+ ` \`paperlint lint\` refuses to run until it parses`,
191
187
  ],
192
188
  bad: 1,
193
189
  };
@@ -204,34 +200,24 @@ function declarationVerdict(raw: string | null): {
204
200
  }
205
201
 
206
202
  /**
207
- * The papers-directory verdict: whether the CLI and the hooks agree, and whether the directory
208
- * they name exists. `bad` counts the failures.
203
+ * The papers-directory verdict: whether the directory the CLI and the hooks read exists, and
204
+ * whether the papers live somewhere else. `bad` counts the failures.
209
205
  */
210
206
  function papersVerdict(
211
207
  root: string,
212
- cliPapers: string | null,
213
208
  hookSays: string | null,
214
209
  ): { lines: string[]; bad: number } {
215
210
  const out: string[] = [];
216
211
  let bad = 0;
217
- if (cliPapers && hookSays) {
218
- const same = resolve(root, cliPapers) === resolve(root, hookSays);
219
- out.push(
220
- same
221
- ? ` ✓ the same directory — what is linted is what is guarded`
222
- : ` ✗ DIFFERENT directories. Every Bash write to ${cliPapers} passes the guard unseen.`,
223
- );
224
- if (!same) bad++;
225
- }
226
212
  // A declared directory that does not exist is a failure only when papers live SOMEWHERE ELSE:
227
- // then every write to them passes the guard unseen (issue #33). With no papers anywhere, the
213
+ // then lint and the hooks watch nothing while the papers go unchecked (issue #33). With no papers anywhere, the
228
214
  // project is simply new — `init --yes` declares the default and creates no paper — and failing
229
215
  // it would teach people to ignore doctor.
230
216
  if (hookSays && !existsSync(join(root, hookSays))) {
231
217
  const guesses = detectPapers(root);
232
218
  if (guesses.length) {
233
219
  out.push(
234
- ` ✗ ${hookSays} does not exist — the guard is watching nothing`,
220
+ ` ✗ ${hookSays} does not exist — lint and the hooks are watching nothing`,
235
221
  );
236
222
  out.push(` papers look like they live in: ${guesses.join(", ")}`);
237
223
  bad++;
@@ -283,8 +269,8 @@ function skillsLines(links: LinkReport, on: boolean): readonly string[] {
283
269
  * 🔴 THE HOOKS ARE READ FROM THE FILE THAT CARRIES THEM. Until `init` wrote them into
284
270
  * `.claude/settings.json`, the only carrier was a plugin and this section said "cannot be checked
285
271
  * from a terminal". Hooks wired NOT AT ALL are advisory, like the skills: `--no-hooks` is a choice,
286
- * not a fault. Partly wired, or wired twice, is a fault and fails the run — unless the plugin is on,
287
- * which carries them.
272
+ * not a fault. Partly wired, wired twice, or a retired hook still wired, is a fault and fails the run —
273
+ * unless the plugin is on, which carries them.
288
274
  */
289
275
  function hooksSection(
290
276
  root: string,
@@ -292,7 +278,12 @@ function hooksSection(
292
278
  ): { readonly lines: readonly string[]; readonly bad: number } {
293
279
  if (on) return { lines: [`hooks`, ` ✓ carried by the plugin`], bad: 0 };
294
280
  try {
295
- return doctorHooks(root);
281
+ const wired = doctorHooks(root);
282
+ const retired = retiredWired(root);
283
+ return {
284
+ lines: [...wired.lines, ...retiredLines(retired)],
285
+ bad: wired.bad + (retired.length > 0 ? 1 : 0),
286
+ };
296
287
  } catch (e) {
297
288
  return { lines: [`hooks`, ` ⚠ not checked — ${messageOf(e)}`], bad: 0 };
298
289
  }
@@ -315,7 +306,7 @@ export interface DoctorOptions {
315
306
  }
316
307
 
317
308
  /**
318
- * @returns 2 when the guard and the linter do not agree, the declaration is unusable, or the hooks
309
+ * @returns 2 when the papers live outside the declared directory, the declaration is unusable, or the hooks
319
310
  * are miswired (partly wired, or one wired twice) — those are binary and are the reason this
320
311
  * command exists. A missing external program is a FACT, not a
321
312
  * verdict: it is printed and does not fail the run, because which programs you need depends on
@@ -348,16 +339,10 @@ export function doctor({
348
339
  bad += declaration.bad;
349
340
 
350
341
  out.push("", "papers directory");
351
- // The hook is given what its provider gives it: the file, or `{}` when there is none.
352
- const hookRoot = papersRoot(raw ?? "{}");
353
- const hookSays = typeof hookRoot === "string" ? hookRoot : null;
354
- out.push(
355
- ` the CLI will lint ${cliPapers ?? "(nothing — no declaration found)"}`,
356
- );
357
342
  out.push(
358
- ` the hooks will guard ${hookSays ?? "(nothing — the guard refuses and says why on first use)"}`,
343
+ ` linted ${cliPapers ?? "(nothing — the settings do not read or name no directory)"}`,
359
344
  );
360
- const verdict = papersVerdict(root, cliPapers, hookSays);
345
+ const verdict = papersVerdict(root, cliPapers);
361
346
  out.push(...verdict.lines);
362
347
  bad += verdict.bad;
363
348
 
@@ -67,7 +67,7 @@ describe("fileHookGate — what the bin decides before it loads the CLI", () =>
67
67
  kind: "other",
68
68
  });
69
69
  expect(
70
- fileHookGate(["hook", "paper-edit-guard"], stdin("x"), files),
70
+ fileHookGate(["hook", "submission-confirm"], stdin("x"), files),
71
71
  ).toEqual({ kind: "other" });
72
72
  expect(fileHookGate([], stdin("x"), files)).toEqual({ kind: "other" });
73
73
  // Guards: a Bash hook reads its own stdin later; reading it here would leave it nothing.