paperlint 18.7.0 → 18.8.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 (88) hide show
  1. package/.claude-plugin/marketplace.json +11 -0
  2. package/.claude-plugin/plugin.json +7 -0
  3. package/CLAUDE.md +2 -2
  4. package/README.md +2 -2
  5. package/dist/adapters/claude-code/claude.io.d.ts +13 -0
  6. package/dist/adapters/claude-code/claude.io.d.ts.map +1 -0
  7. package/dist/adapters/claude-code/claude.io.js +68 -0
  8. package/dist/adapters/claude-code/claude.io.js.map +1 -0
  9. package/dist/adapters/claude-code/index.d.ts +4 -0
  10. package/dist/adapters/claude-code/index.d.ts.map +1 -0
  11. package/dist/adapters/claude-code/index.js +4 -0
  12. package/dist/adapters/claude-code/index.js.map +1 -0
  13. package/dist/adapters/claude-code/plugin.d.ts +19 -0
  14. package/dist/adapters/claude-code/plugin.d.ts.map +1 -0
  15. package/dist/adapters/claude-code/plugin.js +66 -0
  16. package/dist/adapters/claude-code/plugin.js.map +1 -0
  17. package/dist/cli.d.ts +6 -1
  18. package/dist/cli.d.ts.map +1 -1
  19. package/dist/cli.js +34 -10
  20. package/dist/cli.js.map +1 -1
  21. package/dist/doctor-plugin.d.ts +23 -0
  22. package/dist/doctor-plugin.d.ts.map +1 -0
  23. package/dist/doctor-plugin.js +56 -0
  24. package/dist/doctor-plugin.js.map +1 -0
  25. package/dist/doctor.d.ts +6 -1
  26. package/dist/doctor.d.ts.map +1 -1
  27. package/dist/doctor.js +69 -26
  28. package/dist/doctor.js.map +1 -1
  29. package/dist/hooks-settings.d.ts +18 -0
  30. package/dist/hooks-settings.d.ts.map +1 -1
  31. package/dist/hooks-settings.js +25 -0
  32. package/dist/hooks-settings.js.map +1 -1
  33. package/dist/init.d.ts +9 -1
  34. package/dist/init.d.ts.map +1 -1
  35. package/dist/init.js +144 -59
  36. package/dist/init.js.map +1 -1
  37. package/dist/link-skills.d.ts +15 -0
  38. package/dist/link-skills.d.ts.map +1 -1
  39. package/dist/link-skills.js +18 -1
  40. package/dist/link-skills.js.map +1 -1
  41. package/dist/plugin-offer.d.ts +73 -0
  42. package/dist/plugin-offer.d.ts.map +1 -0
  43. package/dist/plugin-offer.js +96 -0
  44. package/dist/plugin-offer.js.map +1 -0
  45. package/dist/ports/claude-code.d.ts +31 -0
  46. package/dist/ports/claude-code.d.ts.map +1 -0
  47. package/dist/ports/claude-code.js +2 -0
  48. package/dist/ports/claude-code.js.map +1 -0
  49. package/dist/types.d.ts +4 -0
  50. package/dist/types.d.ts.map +1 -1
  51. package/docs/install.md +62 -14
  52. package/hooks/CLAUDE.md +2 -2
  53. package/hooks/CLAUDE.md.spec.ts +1 -1
  54. package/lib/skill-checks.mjs +6 -7
  55. package/package.json +4 -1
  56. package/plugin/CLAUDE.md +22 -14
  57. package/plugin/CLAUDE.md.spec.ts +20 -12
  58. package/scripts/plugin-version.test.ts +80 -0
  59. package/scripts/plugin-version.ts +58 -0
  60. package/skills/CLAUDE.md +2 -2
  61. package/skills/CLAUDE.md.spec.ts +1 -1
  62. package/skills/paper-pipeline/references/anonymization.md +4 -3
  63. package/skills/submit-paper/SKILL.md +5 -4
  64. package/skills/submit-paper/SKILL.md.spec.ts +4 -3
  65. package/skills/submit-paper/check-deanon.sh +17 -2
  66. package/skills/submit-paper/check-deanon.test.ts +141 -0
  67. package/src/adapters/claude-code/claude.io.ts +103 -0
  68. package/src/adapters/claude-code/index.test.ts +233 -0
  69. package/src/adapters/claude-code/index.ts +11 -0
  70. package/src/adapters/claude-code/plugin.ts +82 -0
  71. package/src/cli.harness.mjs +6 -0
  72. package/src/cli.test.ts +87 -1
  73. package/src/cli.ts +56 -7
  74. package/src/doctor-plugin.test.ts +103 -0
  75. package/src/doctor-plugin.ts +83 -0
  76. package/src/doctor.test.ts +111 -2
  77. package/src/doctor.ts +83 -32
  78. package/src/hooks-notice.test.ts +82 -0
  79. package/src/hooks-settings.ts +49 -0
  80. package/src/init-plugin.test.ts +178 -0
  81. package/src/init.ts +225 -64
  82. package/src/link-skills.test.ts +34 -1
  83. package/src/link-skills.ts +34 -0
  84. package/src/parse-args.test.ts +2 -0
  85. package/src/plugin-offer.test.ts +276 -0
  86. package/src/plugin-offer.ts +160 -0
  87. package/src/ports/claude-code.ts +30 -0
  88. package/src/types.ts +4 -0
@@ -3,20 +3,28 @@ import { file, instructionFile, prose } from "vigiles/spec";
3
3
 
4
4
  export default instructionFile({
5
5
  sections: {
6
- "`plugin/`": prose`Not a plugin any more. ${file("plugin/hooks/hooks.json")} is the hook wiring that \`paperlint init\` merges
7
- into the consumer's \`.claude/settings.json\`, and it is the only source of that wiring.`,
6
+ "`plugin/`": prose`${file("plugin/hooks/hooks.json")} is the one hook wiring. The Claude Code plugin
7
+ (${file(".claude-plugin/plugin.json")}) ships it as its hooks, and \`paperlint init --no-plugin\` merges the
8
+ same file into the consumer's \`.claude/settings.json\`. Every command in it runs the project's installed
9
+ \`node_modules/paperlint/bin/paperlint.mjs\`: the plugin carries the skills and the hooks, the npm package
10
+ carries the code, and \`paperlint lint\` works without the plugin.`,
8
11
 
9
- "Why there is no Claude Code plugin": prose`There is no Claude Code plugin or marketplace entry; it was removed in the release after 1.0.0
10
- (#82). Do not bring it back without answering each of these, measured (${file("docs/install.md")},
11
- "Why it is shaped this way"):
12
+ "Why the plugin came back": prose`The plugin was removed after 1.0.0 (#82) on three objections. Each now has a measured answer
13
+ (2026-11-22); bring none of them back as a reason without measuring again:
12
14
 
13
- - **A plugin cannot carry the code.** Claude Code installs a plugin's dependencies with a 60-second
14
- timeout, and a failed install never blocks the plugin: the hooks load and fail with
15
- \`cannot find module vigiles\`, silently.
16
- - **The skills need the npm package anyway.** 23 of 24 skills ran scripts that resolve only through
17
- \`node_modules/paperlint/\`.
18
- - **Its manifests carried versions nothing updated**, and Claude Code decides plugin updates from
19
- that number.`,
15
+ - **"A plugin cannot carry the code."** It does not have to. The skill scripts are bundled
16
+ (\`scripts/bundle-skills.ts\`, #624) and run from a copy of the package with no \`node_modules\`; the
17
+ hooks call the project's installed paperlint. Installing the plugin from the marketplace took 16.7 s.
18
+ - **"The skills need the npm package anyway."** Only the hooks do, and they find it in the project.
19
+ - **"Its manifests carried versions nothing updated."** The marketplace installs from the npm package,
20
+ and \`npm pack\` stamps the package's version into the packed \`plugin.json\`
21
+ (${file("scripts/plugin-version.ts")}); the tracked file keeps the placeholder. Without a version there,
22
+ Claude Code lists the plugin's version as "unknown".
23
+
24
+ Turning it on is \`claude\`'s own two commands (\`src/adapters/claude-code/claude.io.ts\`): writing
25
+ \`enabledPlugins\` and \`extraKnownMarketplaces\` by hand left \`claude plugin list\` empty. Repository
26
+ settings alone download nothing in a cloud session either: the user adds the marketplace once in
27
+ their claude.ai settings.`,
20
28
  },
21
29
  rules: {},
22
30
  });
@@ -0,0 +1,80 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { describe, expect, it } from "vitest";
6
+ import { useTempDir, writeTree } from "../test/support.ts";
7
+ import { main, PLACEHOLDER, withVersion } from "./plugin-version.ts";
8
+
9
+ const dir = useTempDir("paperlint-plugin-version-");
10
+ const MANIFEST = {
11
+ name: "paperlint",
12
+ version: PLACEHOLDER,
13
+ skills: "./skills/",
14
+ };
15
+
16
+ const packageAt = (name: string, pkg: object): string => {
17
+ const root = join(dir, name);
18
+ writeTree(root, {
19
+ "package.json": JSON.stringify(pkg),
20
+ ".claude-plugin/plugin.json": JSON.stringify(MANIFEST),
21
+ });
22
+ return root;
23
+ };
24
+ const manifestOf = (root: string): unknown =>
25
+ JSON.parse(readFileSync(join(root, ".claude-plugin", "plugin.json"), "utf8"));
26
+
27
+ describe("plugin-version", () => {
28
+ it("stamp writes the package's version, restore puts the placeholder back, the rest kept", () => {
29
+ const root = packageAt("release", { version: "1.2.3" });
30
+ const stamped = [main("stamp", root), manifestOf(root)];
31
+ const restored = [main("restore", root), manifestOf(root)];
32
+ expect([stamped, restored]).toEqual([
33
+ [0, { ...MANIFEST, version: "1.2.3" }],
34
+ [0, MANIFEST],
35
+ ]);
36
+ });
37
+
38
+ it("a package.json without a version stamps the placeholder; an unknown verb writes nothing", () => {
39
+ const root = packageAt("bare", { name: "x" });
40
+ expect([
41
+ main("stamp", root),
42
+ main("publish", root),
43
+ main(undefined, root),
44
+ manifestOf(root),
45
+ ]).toEqual([0, 2, 2, MANIFEST]);
46
+ });
47
+
48
+ it("withVersion: the two-space form with a final newline; a manifest that is not an object is refused", () => {
49
+ expect(withVersion('{"name":"p"}', "9.9.9")).toBe(
50
+ '{\n "name": "p",\n "version": "9.9.9"\n}\n',
51
+ );
52
+ expect(() => withVersion("[1]", "9.9.9")).toThrow(
53
+ "plugin.json is not a JSON object",
54
+ );
55
+ });
56
+
57
+ it("run as npm runs it: a verb it does not know exits 2 and names the usage", () => {
58
+ const r = spawnSync(
59
+ process.execPath,
60
+ [fileURLToPath(new URL("plugin-version.ts", import.meta.url)), "pack"],
61
+ { encoding: "utf8" },
62
+ );
63
+ expect([r.status, r.stderr]).toEqual([
64
+ 2,
65
+ "usage: node scripts/plugin-version.ts stamp|restore\n",
66
+ ]);
67
+ });
68
+
69
+ it("the tracked manifest carries the placeholder, as the tracked package.json does", () => {
70
+ const tracked = (file: string): unknown =>
71
+ JSON.parse(readFileSync(new URL(`../${file}`, import.meta.url), "utf8"));
72
+ expect([
73
+ tracked(".claude-plugin/plugin.json"),
74
+ tracked("package.json"),
75
+ ]).toEqual([
76
+ expect.objectContaining({ version: PLACEHOLDER }),
77
+ expect.objectContaining({ version: PLACEHOLDER }),
78
+ ]);
79
+ });
80
+ });
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The packed `.claude-plugin/plugin.json` carries the package's version; the tracked one carries the
3
+ * placeholder semantic-release leaves in `package.json`.
4
+ *
5
+ * 🔴 WHY THE VERSION MUST BE IN plugin.json. The marketplace installs the plugin from the npm package
6
+ * (`.claude-plugin/marketplace.json`, source `npm`). Measured 2026-11-22 (Claude Code 2.1.330): an
7
+ * npm-sourced plugin whose plugin.json and marketplace entry name no version is listed as version
8
+ * "unknown" — Claude Code does not read `package.json` — so neither a person nor `paperlint doctor`
9
+ * could tell which paperlint the plugin's skills and hooks belong to.
10
+ *
11
+ * `npm pack` and `npm publish` run `prepack` (stamp) and `postpack` (restore) around the tarball: by
12
+ * then `@semantic-release/npm` has written the release's version into `package.json`. A local pack
13
+ * of the placeholder stamps the placeholder, so nothing changes.
14
+ */
15
+ import { readFileSync, realpathSync, writeFileSync } from "node:fs";
16
+ import { dirname, join } from "node:path";
17
+ import { fileURLToPath } from "node:url";
18
+
19
+ /** The version the tracked files carry between releases. */
20
+ export const PLACEHOLDER = "0.0.0-semantically-released";
21
+
22
+ const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
23
+
24
+ /** A JSON object's text with its `version` set, in the file's own two-space form. */
25
+ export function withVersion(json: string, version: string): string {
26
+ const parsed: unknown = JSON.parse(json);
27
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
28
+ throw new Error("plugin.json is not a JSON object");
29
+ return `${JSON.stringify({ ...parsed, version }, null, 2)}\n`;
30
+ }
31
+
32
+ /** `stamp`: the package's version into plugin.json; `restore`: the placeholder back. */
33
+ export function main(verb: string | undefined, root: string = ROOT): number {
34
+ const plugin = join(root, ".claude-plugin", "plugin.json");
35
+ const pkg: unknown = JSON.parse(
36
+ readFileSync(join(root, "package.json"), "utf8"),
37
+ );
38
+ const version =
39
+ typeof pkg === "object" && pkg !== null && "version" in pkg
40
+ ? String(pkg.version)
41
+ : PLACEHOLDER;
42
+ const to =
43
+ verb === "stamp" ? version : verb === "restore" ? PLACEHOLDER : null;
44
+ if (to === null) {
45
+ console.error("usage: node scripts/plugin-version.ts stamp|restore");
46
+ return 2;
47
+ }
48
+ writeFileSync(plugin, withVersion(readFileSync(plugin, "utf8"), to));
49
+ return 0;
50
+ }
51
+
52
+ // Imports nothing of the package: `npm pack` runs this before anything else, in a tree it may not resolve.
53
+ const invoked = process.argv[1];
54
+ if (
55
+ invoked !== undefined &&
56
+ realpathSync(invoked) === realpathSync(fileURLToPath(import.meta.url))
57
+ )
58
+ process.exit(main(process.argv[2]));
package/skills/CLAUDE.md CHANGED
@@ -1,4 +1,4 @@
1
- <!-- vigiles:sha256:7c3a2ced786e9294 compiled from skills/CLAUDE.md.spec.ts -->
1
+ <!-- vigiles:sha256:dd8a735385fbcd2d compiled from skills/CLAUDE.md.spec.ts -->
2
2
 
3
3
  # CLAUDE.md
4
4
 
@@ -12,7 +12,7 @@ package's location come from `skills/paper-pipeline/scripts/consumer.mjs`; the l
12
12
 
13
13
  ### Skills Ship In Skills
14
14
 
15
- **Guidance only** — Skills ship in `skills/`, never `.claude/skills/`. `paperlint init` symlinks each one into the consumer's `.claude/skills/<name>`; the link's directory name is the skill's name. `skills/` is the npm layout: of 855 packages scanned, 336 shipped `skills/` against 15 `.claude/skills/`. Rejected: leaving the skills for Claude Code to find inside `node_modules` (`docs/install.md`); a symlink loads at startup, deterministically. A skill for working on paperlint itself (it edits this repository's presets, tests or source) does not ship: it lives in `.claude/skills/<name>/` as a real directory, outside `files`, and no shipped skill or user doc names it (`add-venue`).
15
+ **Guidance only** — Skills ship in `skills/`, never `.claude/skills/`. The Claude Code plugin carries `skills/` as it is (`.claude-plugin/plugin.json`); without the plugin, `paperlint init` symlinks each one into the consumer's `.claude/skills/<name>`, and the link's directory name is the skill's name. `skills/` is the npm layout: of 855 packages scanned, 336 shipped `skills/` against 15 `.claude/skills/`. Rejected: leaving the skills for Claude Code to find inside `node_modules` (`docs/install.md`); a symlink loads at startup, deterministically. A skill for working on paperlint itself (it edits this repository's presets, tests or source) does not ship: it lives in `.claude/skills/<name>/` as a real directory, outside `files`, and no shipped skill or user doc names it (`add-venue`).
16
16
 
17
17
  ### One Owner Per Job
18
18
 
@@ -34,7 +34,7 @@ ${file("src/link-skills.ts")}; install-specific paths are flagged by ${file("esl
34
34
  },
35
35
  rules: {
36
36
  "skills-ship-in-skills": guidance(
37
- "Skills ship in `skills/`, never `.claude/skills/`. `paperlint init` symlinks each one into the consumer's `.claude/skills/<name>`; the link's directory name is the skill's name. `skills/` is the npm layout: of 855 packages scanned, 336 shipped `skills/` against 15 `.claude/skills/`. Rejected: leaving the skills for Claude Code to find inside `node_modules` (`docs/install.md`); a symlink loads at startup, deterministically. A skill for working on paperlint itself (it edits this repository's presets, tests or source) does not ship: it lives in `.claude/skills/<name>/` as a real directory, outside `files`, and no shipped skill or user doc names it (`add-venue`).",
37
+ "Skills ship in `skills/`, never `.claude/skills/`. The Claude Code plugin carries `skills/` as it is (`.claude-plugin/plugin.json`); without the plugin, `paperlint init` symlinks each one into the consumer's `.claude/skills/<name>`, and the link's directory name is the skill's name. `skills/` is the npm layout: of 855 packages scanned, 336 shipped `skills/` against 15 `.claude/skills/`. Rejected: leaving the skills for Claude Code to find inside `node_modules` (`docs/install.md`); a symlink loads at startup, deterministically. A skill for working on paperlint itself (it edits this repository's presets, tests or source) does not ship: it lives in `.claude/skills/<name>/` as a real directory, outside `files`, and no shipped skill or user doc names it (`add-venue`).",
38
38
  ),
39
39
  "one-owner-per-job": guidance(
40
40
  `Each job on a paper's text has one owner skill, and the others hand over to it instead of carrying their own instructions for it: ${owners}. The owners are \`skills/jobs.ts\`; who hands work to whom is each skill's \`flow\`, drawn in \`docs/pipeline.md\` and checked by \`test/pipeline.test.ts\`. A skill that finds a problem it does not own names the owner and stops. A second copy of an owner's rule in another skill is a defect: two copies drift, and the reader follows whichever it read last.`,
@@ -12,9 +12,10 @@ Author/identity strings to find and remove from anything a reviewer sees:
12
12
  ```
13
13
  # Your OWN list of identifiers — names, surnames, handles, repo names, tool names, email.
14
14
  # It is CONSUMER DATA, so it lives in your repository, not in this package:
15
- # .claude/skills/submit-paper/deanon-denylist.txt (one extended regex per line)
16
- bash .claude/skills/submit-paper/check-deanon.sh <paper-dir> # PDF text + artifact/ + inside *.zip
17
- grep -rIiE "$(grep -vE '^\s*(#|$)' .claude/skills/submit-paper/deanon-denylist.txt | paste -sd'|')" <targets>
15
+ # .paperlint/deanon-denylist.txt (one extended regex per line)
16
+ # The gate that greps PDF text + artifact/ + inside *.zip is submit-paper's check-deanon.sh
17
+ # (its step 0 gives the command). By hand, over any other targets:
18
+ grep -rIiE "$(grep -vE '^\s*(#|$)' .paperlint/deanon-denylist.txt | paste -sd'|')" <targets>
18
19
  ```
19
20
 
20
21
  Plus a **non-English script** in the source (an author-language fingerprint — Cyrillic in the example
@@ -4,7 +4,7 @@ description: "End-to-end playbook for submitting a peer-reviewed paper to a doub
4
4
  allowed-tools: [Read, Write, Edit, Grep, Glob, Bash, WebSearch, WebFetch, Skill]
5
5
  ---
6
6
 
7
- <!-- vigiles:sha256:567ef8c125d44ebd compiled from skills/submit-paper/SKILL.md.spec.ts -->
7
+ <!-- vigiles:sha256:04205ded068d1947 compiled from skills/submit-paper/SKILL.md.spec.ts -->
8
8
 
9
9
  # submit-paper — get a reviewed paper from "done" to "ready for review"
10
10
 
@@ -55,10 +55,11 @@ never find it.
55
55
  **MECHANICAL GATE (run it, don't eyeball) — greps the PDF text + every artifact file + inside any
56
56
  `*.zip` for the identity deny-list, exit non-zero on a hit:**
57
57
  ```
58
- bash .claude/skills/submit-paper/check-deanon.sh <paper-dir> [pdf=paper.pdf]
58
+ bash ${CLAUDE_SKILL_DIR}/check-deanon.sh <paper-dir> [pdf=paper.pdf]
59
59
  ```
60
- Must PASS (exit 0) for a double-blind submission. Deny-list: `.claude/skills/submit-paper/deanon-denylist.txt`
61
- (edit as handles/repos change). It guards the
60
+ Must PASS (exit 0) for a double-blind submission. Deny-list: your project's
61
+ `.paperlint/deanon-denylist.txt`, one extended regex per line (edit as handles/repos change); it is
62
+ yours, so it lives in your repository, not in the package. It guards the
62
63
  single highest reject-vector (an artifact README naming real maintainers/repos is invisible to a
63
64
  paper-only read). Only run it on *double-blind* papers — a de-anonymized single-blind PDF is supposed
64
65
  to carry your name and will (correctly) fail. Canonical deny-list rationale → `paper-pipeline/references/anonymization.md`.
@@ -74,10 +74,11 @@ never find it.
74
74
  **MECHANICAL GATE (run it, don't eyeball) — greps the PDF text + every artifact file + inside any
75
75
  \`*.zip\` for the identity deny-list, exit non-zero on a hit:**
76
76
  \`\`\`
77
- bash .claude/skills/submit-paper/check-deanon.sh <paper-dir> [pdf=paper.pdf]
77
+ bash \${CLAUDE_SKILL_DIR}/check-deanon.sh <paper-dir> [pdf=paper.pdf]
78
78
  \`\`\`
79
- Must PASS (exit 0) for a double-blind submission. Deny-list: \`.claude/skills/submit-paper/deanon-denylist.txt\`
80
- (edit as handles/repos change). It guards the
79
+ Must PASS (exit 0) for a double-blind submission. Deny-list: your project's
80
+ \`.paperlint/deanon-denylist.txt\`, one extended regex per line (edit as handles/repos change); it is
81
+ yours, so it lives in your repository, not in the package. It guards the
81
82
  single highest reject-vector (an artifact README naming real maintainers/repos is invisible to a
82
83
  paper-only read). Only run it on *double-blind* papers — a de-anonymized single-blind PDF is supposed
83
84
  to carry your name and will (correctly) fail. Canonical deny-list rationale → \`paper-pipeline/references/anonymization.md\`.
@@ -8,7 +8,7 @@
8
8
  # every artifact file (including inside artifact.zip) so "anonymized" is a checked
9
9
  # fact. Sibling to render-paper/check-render.sh. Spirit: prose isn't policy.
10
10
  #
11
- # Usage: check-deanon.sh <paper-dir> [pdf=paper.pdf] [denylist=<skill>/deanon-denylist.txt]
11
+ # Usage: check-deanon.sh <paper-dir> [pdf=paper.pdf] [denylist=<project>/.paperlint/deanon-denylist.txt]
12
12
  # It auto-scans, in <paper-dir>: the PDF text, everything under artifact/ (if present),
13
13
  # and the contents of any *.zip (artifact bundles). Pass extra paths after the
14
14
  # denylist arg to scan additional dirs/zips.
@@ -22,11 +22,26 @@ set -uo pipefail
22
22
  DIR="${1:?usage: check-deanon.sh <paper-dir> [pdf=paper.pdf] [denylist=...] [extra-paths...]}"
23
23
  PDF="${2:-paper.pdf}"
24
24
  SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
25
- DENY="${3:-$SKILL_DIR/deanon-denylist.txt}"
25
+ NAMED_DENY="${3:-}"
26
26
  shift $(( $# >= 3 ? 3 : $# ))
27
27
  EXTRA=("$@")
28
28
 
29
29
  [ -d "$DIR" ] || { echo "FAIL: no dir $DIR"; exit 2; }
30
+
31
+ # The deny-list is the AUTHOR's data, so it lives in their project, never in this package: under
32
+ # the Claude Code plugin this script runs from the plugin's own folder. The project is
33
+ # $CLAUDE_PROJECT_DIR, else the git repository that holds <paper-dir>. Order: the list named as
34
+ # the third argument, then <project>/.paperlint/deanon-denylist.txt, then a list beside this
35
+ # script (the older place, when the skill was linked into .claude/skills/).
36
+ ROOT="${CLAUDE_PROJECT_DIR:-$(git -C "$DIR" rev-parse --show-toplevel 2>/dev/null || true)}"
37
+ PROJECT_DENY="${ROOT:-<project>}/.paperlint/deanon-denylist.txt"
38
+ if [ -n "$NAMED_DENY" ]; then DENY="$NAMED_DENY"
39
+ elif [ -n "$ROOT" ] && [ -f "$PROJECT_DENY" ]; then DENY="$PROJECT_DENY"
40
+ elif [ -f "$SKILL_DIR/deanon-denylist.txt" ]; then DENY="$SKILL_DIR/deanon-denylist.txt"
41
+ else
42
+ echo "FAIL: no deny-list. Write your identifiers, one extended regex per line, to $PROJECT_DENY"
43
+ exit 2
44
+ fi
30
45
  [ -f "$DENY" ] || { echo "FAIL: no deny-list $DENY"; exit 2; }
31
46
 
32
47
  # Build the active pattern (strip comments/blanks).
@@ -0,0 +1,141 @@
1
+ /**
2
+ * `check-deanon.sh`, the double-blind gate: where it finds the author's deny-list, and both halves
3
+ * of the scan. The deny-list is the author's data, so it lives in their project
4
+ * (`.paperlint/deanon-denylist.txt`), never in the package: under the Claude Code plugin the
5
+ * script runs from the plugin's own folder, where no list of the author's can be.
6
+ */
7
+ import { spawnSync } from "node:child_process";
8
+ import {
9
+ copyFileSync,
10
+ mkdirSync,
11
+ mkdtempSync,
12
+ realpathSync,
13
+ rmSync,
14
+ writeFileSync,
15
+ } from "node:fs";
16
+ import { tmpdir } from "node:os";
17
+ import { dirname, join } from "node:path";
18
+ import { fileURLToPath } from "node:url";
19
+ import { afterEach, describe, expect, it } from "vitest";
20
+
21
+ const SCRIPT = join(dirname(fileURLToPath(import.meta.url)), "check-deanon.sh");
22
+ const made: string[] = [];
23
+ afterEach(() => {
24
+ made.splice(0).forEach((d) => {
25
+ rmSync(d, { recursive: true, force: true });
26
+ });
27
+ });
28
+
29
+ /** A project with one paper whose artifact README says `readme`. */
30
+ const project = (readme: string): { root: string; paper: string } => {
31
+ const root = realpathSync(mkdtempSync(join(tmpdir(), "deanon-")));
32
+ made.push(root);
33
+ const paper = join(root, "papers", "p");
34
+ mkdirSync(join(paper, "artifact"), { recursive: true });
35
+ writeFileSync(join(paper, "artifact", "README.md"), `${readme}\n`);
36
+ return { root, paper };
37
+ };
38
+
39
+ const denyList = (path: string): string => {
40
+ mkdirSync(dirname(path), { recursive: true });
41
+ writeFileSync(path, "# my identifiers\nQuillfeather\n");
42
+ return path;
43
+ };
44
+
45
+ /** Runs the gate with no `CLAUDE_PROJECT_DIR` unless `env` sets one. */
46
+ const run = (
47
+ args: readonly string[],
48
+ {
49
+ script = SCRIPT,
50
+ env = {},
51
+ }: { script?: string; env?: Record<string, string> } = {},
52
+ ) => {
53
+ const inherited = Object.fromEntries(
54
+ Object.entries(process.env).filter(([k]) => k !== "CLAUDE_PROJECT_DIR"),
55
+ );
56
+ const r = spawnSync("bash", [script, ...args], {
57
+ encoding: "utf8",
58
+ cwd: tmpdir(),
59
+ env: { ...inherited, ...env },
60
+ });
61
+ return { status: r.status, stdout: r.stdout };
62
+ };
63
+
64
+ const leak = (paper: string): string =>
65
+ [
66
+ `== check-deanon: ${paper} (pdf=paper.pdf, 1 patterns) ==`,
67
+ ` WARN: ${paper}/paper.pdf not found — PDF not scanned`,
68
+ ` LEAK artifact/README.md:1:by Quillfeather`,
69
+ `-- summary: 1 identifier hit(s) across PDF + artifact + zip`,
70
+ `FAIL: de-anonymization leak(s) above — scrub before submitting double-blind.`,
71
+ ``,
72
+ ].join("\n");
73
+
74
+ describe("check-deanon.sh — where the deny-list comes from", () => {
75
+ it("reads the project's .paperlint/deanon-denylist.txt, the project being CLAUDE_PROJECT_DIR", () => {
76
+ const { root, paper } = project("by Quillfeather");
77
+ denyList(join(root, ".paperlint", "deanon-denylist.txt"));
78
+ expect(run([paper], { env: { CLAUDE_PROJECT_DIR: root } })).toEqual({
79
+ status: 1,
80
+ stdout: leak(paper),
81
+ });
82
+ });
83
+
84
+ it("without CLAUDE_PROJECT_DIR, the project is the git repository that holds the paper", () => {
85
+ const { root, paper } = project("by Quillfeather");
86
+ spawnSync("git", ["init", "-q", root]);
87
+ denyList(join(root, ".paperlint", "deanon-denylist.txt"));
88
+ expect(run([paper])).toEqual({ status: 1, stdout: leak(paper) });
89
+ });
90
+
91
+ it("a deny-list named as the third argument wins over the project's", () => {
92
+ const { root, paper } = project("by Quillfeather");
93
+ mkdirSync(join(root, ".paperlint"));
94
+ writeFileSync(join(root, ".paperlint", "deanon-denylist.txt"), "Nobody\n");
95
+ const named = denyList(join(root, "mine.txt"));
96
+ expect(
97
+ run([paper, "paper.pdf", named], { env: { CLAUDE_PROJECT_DIR: root } }),
98
+ ).toEqual({ status: 1, stdout: leak(paper) });
99
+ });
100
+
101
+ it("a list beside the script, the older place, is still read when the project has none", () => {
102
+ const { root, paper } = project("by Quillfeather");
103
+ const skill = join(root, ".claude", "skills", "submit-paper");
104
+ mkdirSync(skill, { recursive: true });
105
+ copyFileSync(SCRIPT, join(skill, "check-deanon.sh"));
106
+ denyList(join(skill, "deanon-denylist.txt"));
107
+ expect(
108
+ run([paper], {
109
+ script: join(skill, "check-deanon.sh"),
110
+ env: { CLAUDE_PROJECT_DIR: root },
111
+ }),
112
+ ).toEqual({ status: 1, stdout: leak(paper) });
113
+ });
114
+
115
+ it("no deny-list anywhere: exit 2, naming the file to write", () => {
116
+ const { root, paper } = project("by Quillfeather");
117
+ expect(run([paper], { env: { CLAUDE_PROJECT_DIR: root } })).toEqual({
118
+ status: 2,
119
+ stdout:
120
+ `FAIL: no deny-list. Write your identifiers, one extended regex per line, to ` +
121
+ `${root}/.paperlint/deanon-denylist.txt\n`,
122
+ });
123
+ });
124
+ });
125
+
126
+ describe("check-deanon.sh — both halves of the scan", () => {
127
+ it("a clean artifact passes", () => {
128
+ const { root, paper } = project("by Anonymous");
129
+ denyList(join(root, ".paperlint", "deanon-denylist.txt"));
130
+ expect(run([paper], { env: { CLAUDE_PROJECT_DIR: root } })).toEqual({
131
+ status: 0,
132
+ stdout: [
133
+ `== check-deanon: ${paper} (pdf=paper.pdf, 1 patterns) ==`,
134
+ ` WARN: ${paper}/paper.pdf not found — PDF not scanned`,
135
+ `-- summary: 0 identifier hit(s) across PDF + artifact + zip`,
136
+ `PASS: no author-identifying strings found. Safe for double-blind.`,
137
+ ``,
138
+ ].join("\n"),
139
+ });
140
+ });
141
+ });
@@ -0,0 +1,103 @@
1
+ /**
2
+ * `ClaudeCode` over the disk and the `claude` program.
3
+ *
4
+ * 🔴 TURNING THE PLUGIN ON IS `claude`'S OWN TWO COMMANDS WHEN `claude` IS ON PATH. Measured
5
+ * 2026-11-22 (Claude Code 2.1.330, a throwaway HOME): the settings keys alone
6
+ * (`extraKnownMarketplaces` + `enabledPlugins`, written by hand) leave `claude plugin list` empty, and
7
+ * a later `claude plugin install paperlint@paperlint --scope project` then fails with "Plugin
8
+ * \"paperlint\" not found in marketplace \"paperlint\"": the marketplace was never fetched. So with
9
+ * `claude` on PATH the commands run (they write the same keys). Without it the keys are written, so
10
+ * the project declares the plugin for every clone, and the report names the commands still owed.
11
+ */
12
+ import { spawnSync } from "node:child_process";
13
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
14
+ import { homedir } from "node:os";
15
+ import { dirname, join } from "node:path";
16
+ import type { ClaudeCode, EnableResult } from "../../ports/claude-code.ts";
17
+ import { isRecord } from "../../domain/record.ts";
18
+ import {
19
+ configDirOf,
20
+ ENABLE_COMMANDS,
21
+ enabledBy,
22
+ installedVersion,
23
+ withPlugin,
24
+ } from "./plugin.ts";
25
+
26
+ /** A JSON file's value; undefined when it is missing or does not parse. */
27
+ function readJson(path: string): unknown {
28
+ try {
29
+ return JSON.parse(readFileSync(path, "utf8"));
30
+ } catch {
31
+ return undefined;
32
+ }
33
+ }
34
+
35
+ /** Whether `file --version` runs and exits 0. */
36
+ export const onPath = (file: string): boolean =>
37
+ spawnSync(file, ["--version"], { stdio: "ignore" }).status === 0;
38
+
39
+ /** Runs `argv` in `cwd` with the terminal's streams; its exit status, null when it did not run. */
40
+ export const runInherit = (
41
+ [file, ...args]: readonly [string, ...string[]],
42
+ cwd: string,
43
+ ): number | null => spawnSync(file, args, { cwd, stdio: "inherit" }).status;
44
+
45
+ export interface ClaudeDeps {
46
+ /** Where Claude Code keeps the user's settings and plugins (`configDirOf`). */
47
+ readonly configDir: string;
48
+ readonly hasClaude: () => boolean;
49
+ readonly run: typeof runInherit;
50
+ }
51
+
52
+ const settingsFile = (root: string) => join(root, ".claude", "settings.json");
53
+
54
+ const COMMANDS = ENABLE_COMMANDS.map((c) => c.join(" "));
55
+
56
+ /** Writes the plugin keys into the project's settings; the reason when the file is not JSON. */
57
+ function writeKeys(root: string): string | null {
58
+ const path = settingsFile(root);
59
+ const raw = existsSync(path) ? readJson(path) : {};
60
+ if (!isRecord(raw)) return `${path} is not a JSON object`;
61
+ mkdirSync(dirname(path), { recursive: true });
62
+ writeFileSync(path, `${JSON.stringify(withPlugin(raw), null, 2)}\n`);
63
+ return null;
64
+ }
65
+
66
+ export const claudeCode = ({
67
+ configDir = configDirOf(process.env, homedir()),
68
+ hasClaude = () => onPath("claude"),
69
+ run = runInherit,
70
+ }: Partial<ClaudeDeps> = {}): ClaudeCode => ({
71
+ present: (root) => existsSync(join(root, ".claude")) || hasClaude(),
72
+ plugin: (root) => ({
73
+ enabled: enabledBy(
74
+ [
75
+ join(root, ".claude", "settings.local.json"),
76
+ settingsFile(root),
77
+ join(configDir, "settings.json"),
78
+ ].map(readJson),
79
+ ),
80
+ version: installedVersion(
81
+ readJson(join(configDir, "plugins", "installed_plugins.json")),
82
+ root,
83
+ ),
84
+ }),
85
+ enable: (root) => enable(root, { hasClaude, run }),
86
+ });
87
+
88
+ /** `claude`'s two commands when it is on PATH; otherwise the keys, and the commands still owed. */
89
+ function enable(
90
+ root: string,
91
+ { hasClaude, run }: Pick<ClaudeDeps, "hasClaude" | "run">,
92
+ ): EnableResult {
93
+ if (!hasClaude()) {
94
+ const bad = writeKeys(root);
95
+ return bad === null
96
+ ? { ok: true, wrote: settingsFile(root), owed: COMMANDS }
97
+ : { ok: false, reason: bad };
98
+ }
99
+ const failed = ENABLE_COMMANDS.find((argv) => run(argv, root) !== 0);
100
+ return failed === undefined
101
+ ? { ok: true, ran: COMMANDS }
102
+ : { ok: false, reason: `\`${failed.join(" ")}\` failed` };
103
+ }