paperlint 18.5.0 → 18.7.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 (117) hide show
  1. package/CLAUDE.md +3 -3
  2. package/CONTRIBUTING.md +5 -2
  3. package/README.md +6 -6
  4. package/dist/adapters/clack/index.d.ts +3 -0
  5. package/dist/adapters/clack/index.d.ts.map +1 -0
  6. package/dist/adapters/clack/index.js +3 -0
  7. package/dist/adapters/clack/index.js.map +1 -0
  8. package/dist/adapters/clack/prompts.io.d.ts +8 -0
  9. package/dist/adapters/clack/prompts.io.d.ts.map +1 -0
  10. package/dist/adapters/clack/prompts.io.js +20 -0
  11. package/dist/adapters/clack/prompts.io.js.map +1 -0
  12. package/dist/adapters/hotcrp/portal.io.d.ts.map +1 -1
  13. package/dist/adapters/hotcrp/portal.io.js +1 -0
  14. package/dist/adapters/hotcrp/portal.io.js.map +1 -1
  15. package/dist/adapters/hotcrp/response.d.ts.map +1 -1
  16. package/dist/adapters/hotcrp/response.js +15 -0
  17. package/dist/adapters/hotcrp/response.js.map +1 -1
  18. package/dist/adapters/package-manager/index.d.ts +4 -0
  19. package/dist/adapters/package-manager/index.d.ts.map +1 -0
  20. package/dist/adapters/package-manager/index.js +4 -0
  21. package/dist/adapters/package-manager/index.js.map +1 -0
  22. package/dist/adapters/package-manager/install.io.d.ts +3 -0
  23. package/dist/adapters/package-manager/install.io.d.ts.map +1 -0
  24. package/dist/adapters/package-manager/install.io.js +23 -0
  25. package/dist/adapters/package-manager/install.io.js.map +1 -0
  26. package/dist/adapters/package-manager/manager.d.ts +13 -0
  27. package/dist/adapters/package-manager/manager.d.ts.map +1 -0
  28. package/dist/adapters/package-manager/manager.js +22 -0
  29. package/dist/adapters/package-manager/manager.js.map +1 -0
  30. package/dist/adapters/study-registry/index.d.ts +2 -2
  31. package/dist/cli.d.ts +4 -1
  32. package/dist/cli.d.ts.map +1 -1
  33. package/dist/cli.js +47 -9
  34. package/dist/cli.js.map +1 -1
  35. package/dist/domain/submission.d.ts +4 -0
  36. package/dist/domain/submission.d.ts.map +1 -1
  37. package/dist/domain/submission.js.map +1 -1
  38. package/dist/init.d.ts +38 -15
  39. package/dist/init.d.ts.map +1 -1
  40. package/dist/init.js +99 -39
  41. package/dist/init.js.map +1 -1
  42. package/dist/ports/project-install.d.ts +19 -0
  43. package/dist/ports/project-install.d.ts.map +1 -0
  44. package/dist/ports/project-install.js +2 -0
  45. package/dist/ports/project-install.js.map +1 -0
  46. package/dist/ports/prompts.d.ts +31 -0
  47. package/dist/ports/prompts.d.ts.map +1 -0
  48. package/dist/ports/prompts.js +2 -0
  49. package/dist/ports/prompts.js.map +1 -0
  50. package/dist/self-install.d.ts +65 -0
  51. package/dist/self-install.d.ts.map +1 -0
  52. package/dist/self-install.js +145 -0
  53. package/dist/self-install.js.map +1 -0
  54. package/dist/skill-chunks/chunk-65X5HVIJ.js +26462 -0
  55. package/dist/skill-chunks/chunk-6NU6CXUS.js +258 -0
  56. package/dist/skill-chunks/chunk-GRSXIWYF.js +352 -0
  57. package/dist/skill-chunks/chunk-IREAROCV.js +84 -0
  58. package/dist/skill-chunks/chunk-KWK6RT4T.js +24267 -0
  59. package/dist/skill-chunks/chunk-NPQVDEE4.js +19681 -0
  60. package/dist/skill-chunks/chunk-PJ4KNV4J.js +45 -0
  61. package/dist/skill-chunks/dist-UPCJMLBM.js +385 -0
  62. package/dist/skill-chunks/pdfjs-LUMEFOH2.js +39518 -0
  63. package/dist/submission.d.ts +19 -2
  64. package/dist/submission.d.ts.map +1 -1
  65. package/dist/submission.js +121 -17
  66. package/dist/submission.js.map +1 -1
  67. package/docs/e2e.md +10 -0
  68. package/docs/install.md +27 -16
  69. package/docs/prior-art/README.md +2 -0
  70. package/docs/prior-art/one-command-install.md +33 -0
  71. package/docs/prior-art/prompt-libraries.md +32 -0
  72. package/docs/submission.md +19 -4
  73. package/eslint.config.mjs +1 -0
  74. package/lib/skill-checks.mjs +17 -9
  75. package/lib/skill-checks.test.mjs +28 -15
  76. package/lib/skill-corpus.mjs +5 -2
  77. package/package.json +5 -3
  78. package/scripts/bundle-skills.test.ts +226 -0
  79. package/scripts/bundle-skills.ts +304 -0
  80. package/skills/argument-arc/SKILL.md +2 -2
  81. package/skills/argument-arc/SKILL.md.spec.ts +1 -1
  82. package/skills/argument-arc/scripts/headings.js +57 -13
  83. package/skills/build-label-page/scripts/label-page.js +2005 -93
  84. package/skills/cold-read-diff/scripts/cold-read.js +221 -14
  85. package/skills/label-agent-runs/scripts/labels.js +272 -348
  86. package/skills/paper-pipeline/scripts/extract-ref-facts.js +304 -0
  87. package/skills/pc-panel-review/scripts/prior-reviews.js +7244 -12
  88. package/skills/run-agent-grid/scripts/grid-guard.js +562 -627
  89. package/skills/verify-citations/SKILL.md +9 -9
  90. package/skills/verify-citations/SKILL.md.spec.ts +8 -8
  91. package/skills/verify-citations/scripts/bib-authors.js +228 -0
  92. package/skills/verify-citations/scripts/verify-cites.js +816 -0
  93. package/src/adapters/clack/index.ts +2 -0
  94. package/src/adapters/clack/prompts.io.ts +35 -0
  95. package/src/adapters/clack/prompts.test.ts +58 -0
  96. package/src/adapters/hotcrp/portal.io.ts +1 -0
  97. package/src/adapters/hotcrp/portal.test.ts +43 -2
  98. package/src/adapters/hotcrp/response.ts +21 -0
  99. package/src/adapters/package-manager/index.test.ts +67 -0
  100. package/src/adapters/package-manager/index.ts +3 -0
  101. package/src/adapters/package-manager/install.io.ts +27 -0
  102. package/src/adapters/package-manager/manager.ts +33 -0
  103. package/src/cli.harness.mjs +41 -26
  104. package/src/cli.test.ts +93 -2
  105. package/src/cli.ts +80 -7
  106. package/src/domain/submission.ts +4 -0
  107. package/src/init.test.ts +138 -27
  108. package/src/init.ts +128 -72
  109. package/src/ports/project-install.ts +18 -0
  110. package/src/ports/prompts.ts +27 -0
  111. package/src/self-install.test.ts +267 -0
  112. package/src/self-install.ts +224 -0
  113. package/src/submission-fields-run.test.ts +1 -0
  114. package/src/submission-prior-reviews.test.ts +9 -1
  115. package/src/submission-show.test.ts +81 -0
  116. package/src/submission-update.test.ts +164 -6
  117. package/src/submission.ts +208 -24
@@ -0,0 +1,304 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `npm run build`'s second step: bundle every script a skill runs, so it runs with no
4
+ * `node_modules` at all — a Claude Code plugin copy is the tarball unpacked without its
5
+ * dependencies, and there a script that imports `zod` or `#src/…` dies with `ERR_MODULE_NOT_FOUND`
6
+ * before it reads its arguments (test/e2e/install/skill-scripts.e2e.ts measures it).
7
+ *
8
+ * ── LAYOUT ──────────────────────────────────────────────────────────────────────────────────
9
+ * Each entry's bundle is written BESIDE its source as `<name>.js` — the path the skill already
10
+ * runs: `headings.ts` → `headings.js` (replacing tsc's output of the same name), `verify-cites.mjs`
11
+ * → `verify-cites.js`. Code two entries share goes to one chunk folder, `dist/skill-chunks/`, which
12
+ * every entry imports by a relative path. The checkout, a consumer's `node_modules` and a plugin
13
+ * copy all hold the same tree, so the same `node ${CLAUDE_SKILL_DIR}/scripts/<name>.js` runs in all
14
+ * three. Every output is a build output: gitignored, shipped by `files`, never a tracked file — the
15
+ * step refuses before writing anything if one would be.
16
+ *
17
+ * ── `import.meta` IN A MODULE THAT IS NOT THE ENTRY ─────────────────────────────────────────
18
+ * Inside one bundle every module's `import.meta.url` is the bundle's. Two things break: a main
19
+ * guard (`isMain(import.meta.url)`) is true for EVERY module, so a bundle would run a second
20
+ * module's `main()`; and a module that finds the package's data from its own location
21
+ * (`src/package-dirs.ts`) looks beside the bundle instead. So in every module of this repository
22
+ * other than the entry, `import.meta.url`, `.dirname` and `.filename` are rewritten to the module's
23
+ * own source location, relative to the output file it lands in (the source tree ships too). The
24
+ * entry keeps its own: its bundle sits where its source does. Any other use of `import.meta` is
25
+ * refused, and so is an entry that another bundled module imports (its code would leave its file).
26
+ */
27
+ import { execFileSync, spawnSync } from "node:child_process";
28
+ import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
29
+ import { dirname, join, relative, sep } from "node:path";
30
+ import { fileURLToPath } from "node:url";
31
+ import {
32
+ build,
33
+ type BuildOptions,
34
+ type Metafile,
35
+ type OutputFile,
36
+ type Plugin,
37
+ } from "esbuild";
38
+ import ts from "typescript";
39
+ import { isMain } from "../skills/paper-pipeline/scripts/consumer.mjs";
40
+
41
+ const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
42
+
43
+ /** The scripts the skills run (`node ${CLAUDE_SKILL_DIR}/…` in a SKILL.md), as their sources. */
44
+ export const SKILL_ENTRIES: readonly string[] = [
45
+ "skills/argument-arc/scripts/headings.ts",
46
+ "skills/build-label-page/scripts/label-page.ts",
47
+ "skills/cold-read-diff/scripts/cold-read.ts",
48
+ "skills/label-agent-runs/scripts/labels.ts",
49
+ "skills/paper-pipeline/scripts/extract-ref-facts.mjs",
50
+ "skills/pc-panel-review/scripts/prior-reviews.ts",
51
+ "skills/run-agent-grid/scripts/grid-guard.ts",
52
+ "skills/verify-citations/scripts/bib-authors.mjs",
53
+ "skills/verify-citations/scripts/verify-cites.mjs",
54
+ ];
55
+
56
+ /** Where the code shared by two or more entries goes, below the package root. */
57
+ export const CHUNK_DIR = "dist/skill-chunks";
58
+
59
+ /** What one run bundles, and the one effect it asks the world: which paths git tracks. */
60
+ export interface BundlePlan {
61
+ readonly root: string;
62
+ /** Entry sources, relative to `root`. */
63
+ readonly entries: readonly string[];
64
+ /** The chunk folder, relative to `root`; emptied and refilled by every run. */
65
+ readonly chunkDir: string;
66
+ /** Of `paths` (relative to `root`), the ones git tracks. */
67
+ readonly tracked: (
68
+ root: string,
69
+ paths: readonly string[],
70
+ ) => readonly string[];
71
+ }
72
+
73
+ /**
74
+ * CommonJS dependencies call `require` and read `__dirname`; an ES module has neither, so each
75
+ * output file defines them first.
76
+ */
77
+ const BANNER = [
78
+ `import { createRequire as __plCreateRequire } from "node:module";`,
79
+ `import { fileURLToPath as __plFileURLToPath } from "node:url";`,
80
+ `import { dirname as __plDirname } from "node:path";`,
81
+ `const require = __plCreateRequire(import.meta.url);`,
82
+ `const __filename = __plFileURLToPath(import.meta.url);`,
83
+ `const __dirname = __plDirname(__filename);`,
84
+ ].join("\n");
85
+
86
+ /** `path` relative to `root`, with forward slashes. */
87
+ const posix = (root: string, path: string): string =>
88
+ relative(root, path).split(sep).join("/");
89
+
90
+ /**
91
+ * Stands for "the package root, relative to this output file" in a rewritten module, until the
92
+ * file the module lands in (an entry's bundle or a chunk) is known; replaced in every output.
93
+ */
94
+ const ROOT_TOKEN = "__PAPERLINT_BUNDLE_ROOT__";
95
+
96
+ /**
97
+ * What each kept `import.meta` property becomes, given the expression for the module's own URL.
98
+ * `__plFileURLToPath` and `__plDirname` are the BANNER's imports, at the top of every output file.
99
+ */
100
+ const KEPT: Readonly<Record<string, (url: string) => string>> = {
101
+ url: (url) => url,
102
+ filename: (url) => `__plFileURLToPath(${url})`,
103
+ dirname: (url) => `__plDirname(__plFileURLToPath(${url}))`,
104
+ };
105
+
106
+ /** One `import.meta` in a module: its span, and the property read (`""` for a bare `import.meta`). */
107
+ interface MetaUse {
108
+ readonly start: number;
109
+ readonly end: number;
110
+ readonly property: string;
111
+ }
112
+
113
+ /** Every `import.meta` in `code`, found by the TypeScript parser: a comment that quotes one is not one. */
114
+ function metaUses(code: string, file: string): readonly MetaUse[] {
115
+ const kind = file.endsWith("ts") ? ts.ScriptKind.TS : ts.ScriptKind.JS;
116
+ const source = ts.createSourceFile(
117
+ file,
118
+ code,
119
+ ts.ScriptTarget.Latest,
120
+ true,
121
+ kind,
122
+ );
123
+ const visit = (node: ts.Node): readonly MetaUse[] => {
124
+ if (
125
+ !ts.isMetaProperty(node) ||
126
+ node.keywordToken !== ts.SyntaxKind.ImportKeyword
127
+ )
128
+ return node.getChildren(source).flatMap(visit);
129
+ const parent = node.parent;
130
+ const read =
131
+ ts.isPropertyAccessExpression(parent) && parent.expression === node;
132
+ const span = read ? parent : node;
133
+ return [
134
+ {
135
+ start: span.getStart(source),
136
+ end: span.end,
137
+ property: read ? parent.name.text : "",
138
+ },
139
+ ];
140
+ };
141
+ return visit(source);
142
+ }
143
+
144
+ /** `code` of the module at `file`, its `import.meta` rewritten to the module's own source location. */
145
+ function keptLocation(code: string, file: string, root: string): string {
146
+ const rel = posix(root, file);
147
+ const url = `new URL(${JSON.stringify(`${ROOT_TOKEN}/${rel}`)}, import.meta.url).href`;
148
+ const uses = metaUses(code, file).map((u) => ({
149
+ ...u,
150
+ as: KEPT[u.property],
151
+ }));
152
+ const kept = uses.filter(
153
+ (u): u is MetaUse & { as: (url: string) => string } => u.as !== undefined,
154
+ );
155
+ const lost = uses.filter((u) => u.as === undefined);
156
+ if (lost.length > 0)
157
+ throw new Error(
158
+ lost
159
+ .map(
160
+ (u) =>
161
+ `${rel}: ${u.property ? `import.meta.${u.property}` : "import.meta"} cannot be kept correct inside a bundle`,
162
+ )
163
+ .join("\n"),
164
+ );
165
+ return kept.reduceRight(
166
+ (text, u) => text.slice(0, u.start) + u.as(url) + text.slice(u.end),
167
+ code,
168
+ );
169
+ }
170
+
171
+ /** The esbuild plugin that applies `keptLocation` to every module of this tree but the entries. */
172
+ const keepOwnLocation = (
173
+ root: string,
174
+ entries: ReadonlySet<string>,
175
+ ): Plugin => ({
176
+ name: "keep-own-location",
177
+ setup(b) {
178
+ b.onLoad({ filter: /\.[cm]?[jt]s$/ }, (args) => {
179
+ const foreign = args.path.split(sep).includes("node_modules");
180
+ if (foreign || entries.has(args.path)) return undefined;
181
+ const code = readFileSync(args.path, "utf8");
182
+ if (!code.includes("import.meta")) return undefined;
183
+ const loader = args.path.endsWith("ts") ? "ts" : "js";
184
+ return { contents: keptLocation(code, args.path, root), loader };
185
+ });
186
+ },
187
+ });
188
+
189
+ /** An output file's text with `ROOT_TOKEN` replaced by the way from its folder to the root. */
190
+ const located = (root: string, f: OutputFile): string =>
191
+ f.text.replaceAll(ROOT_TOKEN, posix(dirname(f.path), root) || ".");
192
+
193
+ /**
194
+ * The paths of `paths` that git tracks in `root`. Outside a checkout (a source archive, or a
195
+ * git-dependency install, where npm runs `prepare` with no `.git`) nothing is tracked, so none.
196
+ */
197
+ export function gitTracked(
198
+ root: string,
199
+ paths: readonly string[],
200
+ ): readonly string[] {
201
+ const inCheckout =
202
+ spawnSync("git", ["rev-parse", "--is-inside-work-tree"], {
203
+ cwd: root,
204
+ stdio: "ignore",
205
+ }).status === 0;
206
+ if (!inCheckout) return [];
207
+ const out = execFileSync("git", ["ls-files", "-z", "--", ...paths], {
208
+ cwd: root,
209
+ encoding: "utf8",
210
+ stdio: ["ignore", "pipe", "pipe"],
211
+ });
212
+ return out.split("\0").filter((p) => p !== "");
213
+ }
214
+
215
+ /** The entries some other bundled module imports, from esbuild's metafile. */
216
+ const importedEntries = (
217
+ meta: Metafile,
218
+ entries: readonly string[],
219
+ ): readonly string[] =>
220
+ entries.filter((e) =>
221
+ Object.values(meta.inputs).some((input) =>
222
+ input.imports.some((i) => i.path === e),
223
+ ),
224
+ );
225
+
226
+ /** Refuse a plan whose run would break an entry or overwrite a tracked file. */
227
+ function refusals(
228
+ plan: BundlePlan,
229
+ meta: Metafile,
230
+ outputs: readonly string[],
231
+ ): readonly string[] {
232
+ const tracked = plan.tracked(plan.root, outputs);
233
+ return [
234
+ ...tracked.map(
235
+ (p) => `${p} is tracked by git: a bundle must not overwrite it`,
236
+ ),
237
+ ...importedEntries(meta, plan.entries).map(
238
+ (e) =>
239
+ `${e} is an entry and is imported by another bundled module: its code would leave its own file`,
240
+ ),
241
+ ];
242
+ }
243
+
244
+ /**
245
+ * esbuild's options for `plan`: one ES module per entry beside its source, shared code split into
246
+ * `plan.chunkDir`, `#src/…` resolved to the sources, nothing written yet.
247
+ */
248
+ const options = (
249
+ plan: BundlePlan,
250
+ ): BuildOptions & { readonly write: false; readonly metafile: true } => ({
251
+ absWorkingDir: plan.root,
252
+ entryPoints: plan.entries.map((e) => join(plan.root, e)),
253
+ outdir: plan.root,
254
+ outbase: plan.root,
255
+ entryNames: "[dir]/[name]",
256
+ chunkNames: `${plan.chunkDir}/[name]-[hash]`,
257
+ bundle: true,
258
+ splitting: true,
259
+ platform: "node",
260
+ format: "esm",
261
+ target: "node22",
262
+ conditions: ["paperlint-source"],
263
+ banner: { js: BANNER },
264
+ plugins: [
265
+ keepOwnLocation(
266
+ plan.root,
267
+ new Set(plan.entries.map((e) => join(plan.root, e))),
268
+ ),
269
+ ],
270
+ write: false,
271
+ metafile: true,
272
+ logLevel: "silent",
273
+ });
274
+
275
+ /** Bundle `plan.entries`; returns the files written, relative to `plan.root`, sorted. */
276
+ export async function bundleSkills(
277
+ plan: BundlePlan,
278
+ ): Promise<readonly string[]> {
279
+ const result = await build(options(plan));
280
+ const files = result.outputFiles;
281
+ const outputs = files.map((f) => posix(plan.root, f.path)).sort();
282
+ const refused = refusals(plan, result.metafile, outputs);
283
+ if (refused.length > 0)
284
+ throw new Error(`bundle-skills: refused\n ${refused.join("\n ")}`);
285
+ rmSync(join(plan.root, plan.chunkDir), { recursive: true, force: true });
286
+ files.forEach((f) => {
287
+ mkdirSync(dirname(f.path), { recursive: true });
288
+ writeFileSync(f.path, located(plan.root, f));
289
+ });
290
+ return outputs;
291
+ }
292
+
293
+ if (isMain(import.meta.url)) {
294
+ const written = await bundleSkills({
295
+ root: ROOT,
296
+ entries: SKILL_ENTRIES,
297
+ chunkDir: CHUNK_DIR,
298
+ tracked: gitTracked,
299
+ });
300
+ // stderr: `npm pack --json` runs this as `prepare`, and its stdout must stay the JSON.
301
+ process.stderr.write(
302
+ `bundle-skills: wrote ${String(written.length)} files\n ${written.join("\n ")}\n`,
303
+ );
304
+ }
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  name: argument-arc
3
3
  description: Build or repair the paper's argument architecture — the one-sentence-per-section outline, the bottom-up inevitability pass, and the name/number budget. Run it when the reader says the paper throws ideas at them, when a structural objection repeats, or before any large rewrite. Not a prose or length skill.
4
- allowed-tools: [Read, Write, Grep, Glob, Agent]
4
+ allowed-tools: [Read, Write, Grep, Glob, Bash, Agent]
5
5
  ---
6
6
 
7
- <!-- vigiles:sha256:3a416cbcd232144a compiled from skills/argument-arc/SKILL.md.spec.ts -->
7
+ <!-- vigiles:sha256:6a52098196a11a05 compiled from skills/argument-arc/SKILL.md.spec.ts -->
8
8
 
9
9
  # argument-arc — does the paper carry the reader to one conclusion
10
10
 
@@ -14,7 +14,7 @@ export default experimental_skill({
14
14
  name: "argument-arc",
15
15
  description:
16
16
  "Build or repair the paper's argument architecture — the one-sentence-per-section outline, the bottom-up inevitability pass, and the name/number budget. Run it when the reader says the paper throws ideas at them, when a structural objection repeats, or before any large rewrite. Not a prose or length skill.",
17
- tools: ["Read", "Write", "Grep", "Glob", "Agent"],
17
+ tools: ["Read", "Write", "Grep", "Glob", "Bash", "Agent"],
18
18
  body: `
19
19
  # argument-arc — does the paper carry the reader to one conclusion
20
20
 
@@ -1,15 +1,59 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * headings — every heading of a paper, in order (`headings-core.ts`); this file only runs it. A
4
- * consumer runs the compiled `headings.js` (Node strips no types under node_modules).
5
- *
6
- * Usage: node headings.js <paper.tex>
7
- */
8
- import { latexReader } from "#src/adapters/latex/index";
9
- import { nodeFiles } from "#src/adapters/node/index";
10
- import { sourcesCodec } from "#src/adapters/sources-record/index";
11
- import { main } from "./headings-core.js";
12
- process.exitCode = main(process.argv.slice(2), { files: nodeFiles, latex: latexReader, codec: sourcesCodec }, {
2
+ import { createRequire as __plCreateRequire } from "node:module";
3
+ import { fileURLToPath as __plFileURLToPath } from "node:url";
4
+ import { dirname as __plDirname } from "node:path";
5
+ const require = __plCreateRequire(import.meta.url);
6
+ const __filename = __plFileURLToPath(import.meta.url);
7
+ const __dirname = __plDirname(__filename);
8
+ import {
9
+ latexReader,
10
+ sourcesCodec
11
+ } from "../../../dist/skill-chunks/chunk-65X5HVIJ.js";
12
+ import {
13
+ callerPath,
14
+ decoded,
15
+ nodeFiles,
16
+ readPaper,
17
+ runText
18
+ } from "../../../dist/skill-chunks/chunk-6NU6CXUS.js";
19
+ import "../../../dist/skill-chunks/chunk-GRSXIWYF.js";
20
+ import "../../../dist/skill-chunks/chunk-NPQVDEE4.js";
21
+ import "../../../dist/skill-chunks/chunk-PJ4KNV4J.js";
22
+
23
+ // skills/argument-arc/scripts/headings-core.ts
24
+ import { resolve } from "node:path";
25
+ var headingsOf = (file, src, deps) => deps.latex.headings(readPaper(file, src, deps).text).filter((h) => h.command.kind === "heading" && h.argument === "title").map((h) => runText(h.title).replace(/\s+/gu, " ").trim());
26
+ var listing = (name, headings) => [
27
+ `=== ${name} \u2014 every heading, in order ===`,
28
+ ...headings.map((h, i) => `${String(i + 1).padStart(3)}. ${h}`),
29
+ "",
30
+ "Read these as a stranger who will read nothing else. Each should name a thing:",
31
+ 'a linter, a configuration, a repository, a rule \u2014 not "answers", "kinds", "moves".',
32
+ ""
33
+ ].join("\n");
34
+ function main(argv, deps, { out, err }) {
35
+ const [arg] = argv;
36
+ if (arg === void 0) {
37
+ err("usage: node headings.js <paper.tex>\n");
38
+ return 2;
39
+ }
40
+ const file = resolve(arg);
41
+ const src = decoded(deps.files.readBytes(callerPath(file)));
42
+ if (src === null) {
43
+ err(`headings: no file at ${file}
44
+ `);
45
+ return 2;
46
+ }
47
+ out(listing(arg, headingsOf(file, src, deps)));
48
+ return 0;
49
+ }
50
+
51
+ // skills/argument-arc/scripts/headings.ts
52
+ process.exitCode = main(
53
+ process.argv.slice(2),
54
+ { files: nodeFiles, latex: latexReader, codec: sourcesCodec },
55
+ {
13
56
  out: (s) => process.stdout.write(s),
14
- err: (s) => process.stderr.write(s),
15
- });
57
+ err: (s) => process.stderr.write(s)
58
+ }
59
+ );