paperlint 19.0.1 → 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.
- package/.claude-plugin/plugin.json +1 -1
- package/CLAUDE.md +2 -2
- package/dist/CLAUDE.md.spec.d.ts.map +1 -1
- package/dist/CLAUDE.md.spec.js +7 -1
- package/dist/CLAUDE.md.spec.js.map +1 -1
- package/dist/cli.d.ts +2 -21
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +46 -98
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +8 -10
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +27 -37
- package/dist/doctor.js.map +1 -1
- package/dist/folder-layout-hook.js +1 -1
- package/dist/hooks-notice.d.ts +9 -1
- package/dist/hooks-notice.d.ts.map +1 -1
- package/dist/hooks-notice.js +16 -18
- package/dist/hooks-notice.js.map +1 -1
- package/dist/hooks-settings.d.ts +1 -1
- package/dist/hooks-settings.js +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.js +5 -5
- package/dist/lib/paper-config.d.ts +4 -9
- package/dist/lib/paper-config.d.ts.map +1 -1
- package/dist/lib/paper-config.js +4 -9
- package/dist/lib/paper-config.js.map +1 -1
- package/dist/papers-roots.d.ts +19 -0
- package/dist/papers-roots.d.ts.map +1 -0
- package/dist/papers-roots.js +42 -0
- package/dist/papers-roots.js.map +1 -0
- package/dist/retired-hooks.d.ts +6 -0
- package/dist/retired-hooks.d.ts.map +1 -0
- package/dist/retired-hooks.js +34 -0
- package/dist/retired-hooks.js.map +1 -0
- package/dist/skill-chunks/chunk-C2G5EK7S.js +579 -0
- package/dist/skill-chunks/{chunk-UL4INX2P.js → chunk-L3NJUJUP.js} +446 -446
- package/dist/skill-chunks/{chunk-EOVEVX67.js → chunk-X4VKG4KT.js} +1 -1
- package/dist/types.d.ts +1 -1
- package/docs/install.md +12 -14
- package/docs/layout.md +2 -5
- package/docs/rules/paper/allowed-files-only.md +1 -2
- package/docs/testing.md +1 -1
- package/eslint.config.mjs +1 -1
- package/lib/paper-config.harness.mjs +4 -8
- package/lib/paper-config.ts +4 -9
- package/package.json +2 -3
- package/plugin/hooks/hooks.json +0 -22
- package/scripts/coverage-config.test.ts +0 -1
- package/scripts/eslint-file-length.mjs +0 -1
- package/skills/argument-arc/scripts/headings.js +2 -2
- package/skills/build-label-page/scripts/label-page.js +125 -125
- package/skills/cold-read-diff/scripts/cold-read.js +11 -11
- package/skills/paper-pipeline/scripts/extract-ref-facts.js +3 -3
- package/skills/paper-status/SKILL.md +1 -2
- package/skills/paper-status/SKILL.md.spec.ts +0 -1
- package/skills/pc-panel-review/scripts/prior-reviews.js +1 -1
- package/skills/verify-citations/scripts/bib-authors.js +3 -3
- package/skills/verify-citations/scripts/verify-cites.js +3 -3
- package/src/CLAUDE.md +16 -1
- package/src/CLAUDE.md.spec.ts +12 -1
- package/src/cli.harness.mjs +16 -80
- package/src/cli.test.ts +6 -36
- package/src/cli.ts +49 -145
- package/src/doctor.harness.mjs +17 -59
- package/src/doctor.test.ts +1 -1
- package/src/doctor.ts +26 -41
- package/src/domain/paper-folder.test.ts +1 -1
- package/src/folder-layout-hook.ts +1 -1
- package/src/hooks-notice.test.ts +21 -74
- package/src/hooks-notice.ts +37 -18
- package/src/hooks-settings.harness.ts +27 -29
- package/src/hooks-settings.ts +1 -1
- package/src/in-process-hooks.test.ts +18 -0
- package/src/init.ts +5 -5
- package/src/lint-edited-site-example.test.ts +0 -3
- package/src/papers-roots.test.ts +56 -0
- package/src/papers-roots.ts +56 -0
- package/src/retired-hooks.test.ts +155 -0
- package/src/retired-hooks.ts +41 -0
- package/src/types.ts +1 -1
- package/dist/skill-chunks/chunk-GRSXIWYF.js +0 -352
- package/hooks/CLAUDE.md +0 -34
- package/hooks/CLAUDE.md.spec.ts +0 -30
- package/hooks/hooks.harness.ts +0 -704
- package/hooks/paper-edit-guard.hook.d.mts +0 -12
- package/hooks/paper-edit-guard.hook.mjs +0 -443
- package/hooks/paper-edit-guard.test.ts +0 -66
- package/hooks/paper-skills-nudge.hook.d.mts +0 -22
- package/hooks/paper-skills-nudge.hook.mjs +0 -199
- package/hooks/paper-skills-nudge.test.ts +0 -122
- package/hooks/paper-status-gates.hook.mjs +0 -158
- package/hooks/paper-status-gates.sh +0 -93
- package/hooks/paper-status-gates.test.ts +0 -101
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 {
|
|
@@ -250,8 +248,10 @@ import {
|
|
|
250
248
|
noticeText,
|
|
251
249
|
notYetTold,
|
|
252
250
|
recordTold,
|
|
251
|
+
hookNotRunningText,
|
|
253
252
|
} from "./hooks-notice.ts";
|
|
254
253
|
import { unwiredHooks } from "./hooks-settings.ts";
|
|
254
|
+
import { RETIRED_HOOKS, retiredWired } from "./retired-hooks.ts";
|
|
255
255
|
import {
|
|
256
256
|
linkSkills,
|
|
257
257
|
locatePackage,
|
|
@@ -1426,34 +1426,11 @@ export function readConfig(
|
|
|
1426
1426
|
return { opts: settings.value, configPath, root };
|
|
1427
1427
|
}
|
|
1428
1428
|
|
|
1429
|
-
/** The papers directory field of the settings, read by its one declared name; the default when absent. */
|
|
1430
|
-
export function papersDirOf(opts: PaperlintConfig): unknown {
|
|
1431
|
-
const declared = opts.papersDir;
|
|
1432
|
-
return declared === undefined ? DEFAULT_PAPERS_ROOT : declared;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
1429
|
/** The error for a papers directory that is missing or holds no paper. */
|
|
1436
1430
|
export const noPapersMessage = (dir: string): string =>
|
|
1437
1431
|
`no papers in ${dir}/ — create one with \`npx paperlint new <name>\`, or set "${PAPERS_DIR_FIELD}" ` +
|
|
1438
1432
|
`in ${CONFIG_FILE} if your papers live elsewhere`;
|
|
1439
1433
|
|
|
1440
|
-
/** The papers directories of a read config, absolute: each relative to the project root. */
|
|
1441
|
-
export const papersRoots = (cfg: {
|
|
1442
|
-
opts: PaperlintConfig;
|
|
1443
|
-
root: string;
|
|
1444
|
-
}): string[] =>
|
|
1445
|
-
toPaths(papersDirOf(cfg.opts)).map((rel) => resolve(cfg.root, rel));
|
|
1446
|
-
|
|
1447
|
-
/** The papers directory may be one directory or several; both spellings normalise to a list. */
|
|
1448
|
-
export function toPaths(papers: unknown): string[] {
|
|
1449
|
-
if (typeof papers === "string") return papers.trim() ? [papers.trim()] : [];
|
|
1450
|
-
if (Array.isArray(papers))
|
|
1451
|
-
return papers.filter(
|
|
1452
|
-
(x): x is string => typeof x === "string" && x.trim() !== "",
|
|
1453
|
-
);
|
|
1454
|
-
return [];
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
1434
|
/** What an in-process hook is handed: the payload, and where its output and complaints go. */
|
|
1458
1435
|
interface HookIo {
|
|
1459
1436
|
readonly err: typeof console.error;
|
|
@@ -1463,8 +1440,16 @@ interface HookIo {
|
|
|
1463
1440
|
|
|
1464
1441
|
/**
|
|
1465
1442
|
* Hooks that run inside this process instead of as a vigiles program, each because it must call the
|
|
1466
|
-
* package's own code (`src/folder-layout-hook.ts` says why for its one).
|
|
1467
|
-
*
|
|
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.
|
|
1468
1453
|
*/
|
|
1469
1454
|
const IN_PROCESS_HOOKS: Readonly<
|
|
1470
1455
|
Record<string, (io: HookIo) => number | Promise<number>>
|
|
@@ -1514,6 +1499,10 @@ const IN_PROCESS_HOOKS: Readonly<
|
|
|
1514
1499
|
},
|
|
1515
1500
|
};
|
|
1516
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
|
+
|
|
1517
1506
|
/**
|
|
1518
1507
|
* The words after `submission` read by this CLI's own parser, as the command reads them: the paper
|
|
1519
1508
|
* and `--pdf` a send names, null for their defaults — or null when the words would not run cleanly
|
|
@@ -1633,18 +1622,6 @@ const firstLine = (message: string): string => message.split("\n", 1).join("");
|
|
|
1633
1622
|
/** What `runHook` takes; every effect is injectable, so a test stages none of them. */
|
|
1634
1623
|
interface HookOptions {
|
|
1635
1624
|
readonly err?: typeof console.error;
|
|
1636
|
-
/** Runs the hook with the terminal's streams: `spawnSync` is one. Only its status and stdout are read. */
|
|
1637
|
-
readonly run?: (
|
|
1638
|
-
file: string,
|
|
1639
|
-
args: readonly string[],
|
|
1640
|
-
options: {
|
|
1641
|
-
readonly stdio:
|
|
1642
|
-
"inherit" | readonly ["pipe", "pipe" | "inherit", "inherit"];
|
|
1643
|
-
readonly input?: string;
|
|
1644
|
-
readonly encoding?: "utf8";
|
|
1645
|
-
},
|
|
1646
|
-
) => { readonly status: number | null; readonly stdout?: string | null };
|
|
1647
|
-
readonly resolve?: (spec: string) => string;
|
|
1648
1625
|
/** The hook's payload, as Claude Code sends it on stdin. */
|
|
1649
1626
|
readonly stdin?: () => string;
|
|
1650
1627
|
/** Where an in-process hook's output goes: stdout, which Claude Code reads. */
|
|
@@ -1667,22 +1644,6 @@ const defaultOut = (text: string): void => {
|
|
|
1667
1644
|
process.stdout.write(text);
|
|
1668
1645
|
};
|
|
1669
1646
|
|
|
1670
|
-
/** The real spawner, narrowed to what `runHook` asks of it. */
|
|
1671
|
-
export const spawnHook: NonNullable<HookOptions["run"]> = (file, args, o) => {
|
|
1672
|
-
const r =
|
|
1673
|
-
o.stdio === "inherit"
|
|
1674
|
-
? spawnSync(file, [...args], { stdio: "inherit" })
|
|
1675
|
-
: spawnSync(file, [...args], {
|
|
1676
|
-
stdio: [...o.stdio],
|
|
1677
|
-
input: o.input,
|
|
1678
|
-
encoding: "utf8",
|
|
1679
|
-
});
|
|
1680
|
-
return {
|
|
1681
|
-
status: r.status,
|
|
1682
|
-
stdout: typeof r.stdout === "string" ? r.stdout : null,
|
|
1683
|
-
};
|
|
1684
|
-
};
|
|
1685
|
-
|
|
1686
1647
|
/** The project root the hooks are anchored to. */
|
|
1687
1648
|
const hookRoot = (io: HookOptions): string =>
|
|
1688
1649
|
io.projectDir ?? process.env["CLAUDE_PROJECT_DIR"] ?? process.cwd();
|
|
@@ -1709,11 +1670,13 @@ function owed(
|
|
|
1709
1670
|
readonly missing: readonly string[];
|
|
1710
1671
|
readonly byHand: boolean;
|
|
1711
1672
|
readonly skills: readonly string[];
|
|
1673
|
+
readonly retired: readonly string[];
|
|
1712
1674
|
} {
|
|
1713
1675
|
if (installedPluginVersion(claude.plugin(absolutePath(root))) !== null)
|
|
1714
|
-
return { missing: [], byHand: false, skills: [] };
|
|
1676
|
+
return { missing: [], byHand: false, skills: [], retired: [] };
|
|
1715
1677
|
const { missing, byHand } = unwiredHooks(root);
|
|
1716
|
-
|
|
1678
|
+
const skills = unlinkedSkills(skillLinks(root));
|
|
1679
|
+
return { missing, byHand, skills, retired: retiredWired(root) };
|
|
1717
1680
|
}
|
|
1718
1681
|
|
|
1719
1682
|
interface Pending {
|
|
@@ -1729,16 +1692,22 @@ interface Pending {
|
|
|
1729
1692
|
function pendingNotice(io: ResolvedHookOptions): Pending | null {
|
|
1730
1693
|
try {
|
|
1731
1694
|
const root = hookRoot(io);
|
|
1732
|
-
const { missing, byHand, skills } = owed(
|
|
1695
|
+
const { missing, byHand, skills, retired } = owed(
|
|
1733
1696
|
root,
|
|
1734
1697
|
io.skillLinks ?? readSkillLinks,
|
|
1735
1698
|
io.claude ?? claudeCode(),
|
|
1736
1699
|
);
|
|
1737
1700
|
const version = io.version ?? packageVersion();
|
|
1738
|
-
return (missing.length === 0 &&
|
|
1701
|
+
return (missing.length === 0 &&
|
|
1702
|
+
skills.length === 0 &&
|
|
1703
|
+
retired.length === 0) ||
|
|
1739
1704
|
!notYetTold(nodeFiles, root, version)
|
|
1740
1705
|
? null
|
|
1741
|
-
: {
|
|
1706
|
+
: {
|
|
1707
|
+
text: noticeText(version, missing, byHand, { skills, retired }),
|
|
1708
|
+
root,
|
|
1709
|
+
version,
|
|
1710
|
+
};
|
|
1742
1711
|
} catch (e) {
|
|
1743
1712
|
io.err(
|
|
1744
1713
|
`paperlint: the unwired-hooks check did not run: ${firstLine(messageOf(e))}`,
|
|
@@ -1773,22 +1742,16 @@ function hooksLine(
|
|
|
1773
1742
|
}
|
|
1774
1743
|
}
|
|
1775
1744
|
|
|
1776
|
-
const after = (
|
|
1777
|
-
code: number | Promise<number>,
|
|
1778
|
-
then: (code: number) => number,
|
|
1779
|
-
): number | Promise<number> =>
|
|
1780
|
-
typeof code === "number" ? then(code) : code.then(then);
|
|
1781
|
-
|
|
1782
1745
|
/**
|
|
1783
1746
|
* The hook as always, with the notice added to what it printed — when its payload is about a paper's
|
|
1784
1747
|
* file. The payload is read once and handed on; anything outside a paper, or unreadable, runs the hook
|
|
1785
1748
|
* untouched and leaves the notice for the next edit that is about a paper.
|
|
1786
1749
|
*/
|
|
1787
|
-
function runHookWithNotice(
|
|
1750
|
+
async function runHookWithNotice(
|
|
1788
1751
|
name: string,
|
|
1789
1752
|
notice: Pending,
|
|
1790
1753
|
io: ResolvedHookOptions,
|
|
1791
|
-
):
|
|
1754
|
+
): Promise<number> {
|
|
1792
1755
|
const text = ((): string | null => {
|
|
1793
1756
|
try {
|
|
1794
1757
|
return io.stdin();
|
|
@@ -1797,23 +1760,17 @@ function runHookWithNotice(
|
|
|
1797
1760
|
}
|
|
1798
1761
|
})();
|
|
1799
1762
|
if (text === null) return runHookPlain(name, io);
|
|
1800
|
-
const fed = { ...io, stdin: () => text
|
|
1763
|
+
const fed = { ...io, stdin: () => text };
|
|
1801
1764
|
if (!touchesAPaper(text)) return runHookPlain(name, fed);
|
|
1802
1765
|
const printed = collector();
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
const merged = code === 0 ? mergeNotice(said, notice.text) : null;
|
|
1812
|
-
// Remembered BEFORE it is said: a state that cannot be written must not make the notice repeat on every edit.
|
|
1813
|
-
io.out(merged !== null && remember(notice, io) ? merged : said);
|
|
1814
|
-
return code;
|
|
1815
|
-
},
|
|
1816
|
-
);
|
|
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;
|
|
1817
1774
|
}
|
|
1818
1775
|
|
|
1819
1776
|
/** Records that the notice was given; false, with one stderr line, when it cannot be. */
|
|
@@ -1831,68 +1788,15 @@ function remember(notice: Pending, io: ResolvedHookOptions): boolean {
|
|
|
1831
1788
|
|
|
1832
1789
|
function runHookPlain(
|
|
1833
1790
|
name: string | undefined,
|
|
1834
|
-
{
|
|
1835
|
-
err = console.error,
|
|
1836
|
-
run = spawnHook,
|
|
1837
|
-
// The resolver is injected so that "the runtime was not found" is checked by an assert and not
|
|
1838
|
-
// by deleting node_modules: a failure must be reproducible, not staged.
|
|
1839
|
-
// 🔴 WE RESOLVE THE PACKAGE, NOT A FILE INSIDE IT. `require.resolve("vigiles/dist/cli.js")`
|
|
1840
|
-
// DOES NOT WORK: the package's `exports` map hands out only "." and nine named subpaths, and
|
|
1841
|
-
// `./dist/cli.js` — even `./package.json` — is not among them:
|
|
1842
|
-
// Package subpath './dist/cli.js' is not defined by "exports"
|
|
1843
|
-
// This is neither our oversight nor their bug: a closed export map is normal practice. So we
|
|
1844
|
-
// resolve the root entry ("." → dist/test.js), take its directory and put `cli.js` next to it —
|
|
1845
|
-
// the very file the package itself declares as its `bin`.
|
|
1846
|
-
resolve = (spec: string): string =>
|
|
1847
|
-
createRequire(import.meta.url).resolve(spec),
|
|
1848
|
-
stdin = defaultStdin,
|
|
1849
|
-
out = defaultOut,
|
|
1850
|
-
feed,
|
|
1851
|
-
capture = false,
|
|
1852
|
-
}: HookOptions & {
|
|
1853
|
-
/** The payload already read from stdin, handed to a spawned hook on its stdin. */
|
|
1854
|
-
readonly feed?: string;
|
|
1855
|
-
/** Collect a spawned hook's stdout into `out` instead of letting it reach the terminal. */
|
|
1856
|
-
readonly capture?: boolean;
|
|
1857
|
-
} = {},
|
|
1791
|
+
{ err, stdin, out }: ResolvedHookOptions,
|
|
1858
1792
|
): number | Promise<number> {
|
|
1859
|
-
|
|
1860
|
-
err(`\`hook\` needs a name, e.g. \`paperlint hook paper-edit-guard\``);
|
|
1861
|
-
return 2;
|
|
1862
|
-
}
|
|
1863
|
-
const inProcess = IN_PROCESS_HOOKS[name];
|
|
1793
|
+
const inProcess = IN_PROCESS_HOOKS[name ?? ""];
|
|
1864
1794
|
if (inProcess !== undefined) return inProcess({ err, stdin, out });
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
);
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
return 2;
|
|
1871
|
-
}
|
|
1872
|
-
let runtime;
|
|
1873
|
-
try {
|
|
1874
|
-
runtime = join(dirname(resolve("vigiles")), "cli.js");
|
|
1875
|
-
if (!existsSync(runtime))
|
|
1876
|
-
throw new Error(`resolved vigiles, but no cli.js beside it: ${runtime}`);
|
|
1877
|
-
} catch {
|
|
1878
|
-
err(
|
|
1879
|
-
`paperlint: the hook runtime (vigiles) is not resolvable from ${fileURLToPath(new URL(".", import.meta.url))}.\n` +
|
|
1880
|
-
`The \`${name}\` hook is NOT running. Everything else — \`paperlint lint\`, CI — is unaffected.\n` +
|
|
1881
|
-
`Reinstall this package so its dependencies are present.`,
|
|
1882
|
-
);
|
|
1883
|
-
return 0;
|
|
1884
|
-
}
|
|
1885
|
-
const args = [runtime, "hook-runtime", "run-program", program];
|
|
1886
|
-
const r =
|
|
1887
|
-
feed === undefined
|
|
1888
|
-
? run(process.execPath, args, { stdio: "inherit" })
|
|
1889
|
-
: run(process.execPath, args, {
|
|
1890
|
-
stdio: ["pipe", capture ? "pipe" : "inherit", "inherit"],
|
|
1891
|
-
input: feed,
|
|
1892
|
-
encoding: "utf8",
|
|
1893
|
-
});
|
|
1894
|
-
if (capture && typeof r.stdout === "string") out(r.stdout);
|
|
1895
|
-
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
|
|
1896
1800
|
}
|
|
1897
1801
|
|
|
1898
1802
|
/**
|
|
@@ -2738,7 +2642,7 @@ export async function run(
|
|
|
2738
2642
|
// an explicable one.
|
|
2739
2643
|
let results: ESLint.LintResult[];
|
|
2740
2644
|
try {
|
|
2741
|
-
results = await eslint.lintFiles(paths);
|
|
2645
|
+
results = await eslint.lintFiles([...paths]);
|
|
2742
2646
|
} catch (e) {
|
|
2743
2647
|
if (isEmptyLintSet(e)) results = [];
|
|
2744
2648
|
else throw e;
|
package/src/doctor.harness.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* file.
|
|
4
4
|
*
|
|
5
5
|
* 🔴 WHY A TEST MATTERS ESPECIALLY MUCH HERE. Doctor exists precisely because
|
|
6
|
-
*
|
|
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
|
|
82
|
-
/
|
|
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:
|
|
88
|
-
// The
|
|
89
|
-
//
|
|
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: "
|
|
89
|
+
const r = runDoctor(dir, { cliPapers: "papers" });
|
|
93
90
|
check(
|
|
94
|
-
"
|
|
91
|
+
"papers outside the declared directory — a FAILURE, not a cheerful report",
|
|
95
92
|
r.code === 2,
|
|
96
93
|
);
|
|
97
94
|
check(
|
|
98
|
-
"
|
|
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 —
|
|
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
|
|
127
|
+
"named, with what it blocks",
|
|
140
128
|
/✗ paperlint\.json is not valid JSON/.test(r.out) &&
|
|
141
|
-
|
|
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:
|
|
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
|
-
// ──
|
|
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:
|
|
158
|
+
const r = runDoctor(dir, { cliPapers: null });
|
|
201
159
|
check(
|
|
202
|
-
"an empty string in the declaration —
|
|
203
|
-
/
|
|
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
|
}
|
package/src/doctor.test.ts
CHANGED
|
@@ -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("
|
|
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
|
|
7
|
-
*
|
|
8
|
-
*
|
|
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
|
|
12
|
-
* that
|
|
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
|
|
17
|
-
*
|
|
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 "
|
|
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
|
-
*
|
|
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
|
-
`
|
|
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
|
|
208
|
-
*
|
|
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
|
|
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
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
-
`
|
|
343
|
+
` linted ${cliPapers ?? "(nothing — the settings do not read or name no directory)"}`,
|
|
359
344
|
);
|
|
360
|
-
const verdict = papersVerdict(root, cliPapers
|
|
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", "
|
|
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.
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* ── WHY IT IS NOT A VIGILES PROGRAM LIKE ITS NEIGHBOURS (measured 2026-10-12, vigiles 38) ──────
|
|
29
29
|
* A shipped `.hook.mjs` may import nothing but `vigiles/hook` (`checkHookImports`), so it cannot call
|
|
30
30
|
* this package's function; its only way to a tool is `run()`, whose output reaches stderr and never
|
|
31
|
-
* the hook's answer (
|
|
31
|
+
* the hook's answer (measured 2026-09-12, vigiles 27); and a `provide()` command runs
|
|
32
32
|
* before the reaction without the event, so it cannot know which file is written. Each of the three
|
|
33
33
|
* would mean a second copy of the layout. So `paperlint hook paper-folder-layout` runs this module
|
|
34
34
|
* in-process (`runHook`, src/cli.ts), behind the same wiring command as the other hooks, which is
|