@nshiab/setup-data-project 4.0.11 → 4.0.13

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/README.md CHANGED
@@ -60,7 +60,7 @@ npx @nshiab/setup-data-project@latest --sda
60
60
  Without library flags, the interactive setup asks whether to keep each selected
61
61
  installed library's existing version or update it to latest.
62
62
 
63
- The project includes `sda/main.ts`, helpers, data and output folders,
63
+ The project includes `sda/main.ts`, helpers, test, data and output folders,
64
64
  `.env`, `.gitignore`, and managed sections in README.md and AGENTS.md.
65
65
  Existing source files, environment values, scripts, tooling configuration,
66
66
  and unmanaged documentation are preserved.
@@ -68,13 +68,15 @@ Remove the generated section or its markers from README.md or AGENTS.md to stop
68
68
 
69
69
  Generated projects run TypeScript directly with Node or Bun. Oxfmt and Oxlint
70
70
  provide formatting, linting, and TypeScript checking through oxlint-tsgolint.
71
- Put tests in `sda/test/`. Use these commands
71
+ Put tests in `sda/test/` and name them `*.test.ts`. Bun projects need Bun 1.3.1
72
+ or newer for the empty test suite to pass. Use these commands
72
73
  (replace `npm run` with `bun run` for Bun projects):
73
74
 
74
75
  - `npm run sda`: run `fix`, then execute `sda/main.ts` once if checks pass.
75
76
  - `npm run sda:watch`: do the same on changes to `sda/` and `.env`, excluding `sda/output/`.
76
77
  - `npm run sda:status`: check whether an SDA run or watcher is active.
77
- - `npm run all-tests`: check formatting, lint, and TypeScript types. When adding tests, extend this script to run them after the existing checks.
78
+ - `npm run sda:tests`: check formatting, lint, and TypeScript types, then run the tests in `sda/test/`.
79
+ - `npm run sda:tests:watch`: rerun those checks and tests on changes to `sda/`, `.env`, and `tsconfig.json`, excluding `sda/output/`.
78
80
  - `npm run fix`: format files, apply automatic lint fixes, and check types.
79
81
  - `npm run docs`: refresh documentation for the installed library versions.
80
82
  - `npm run clean`: delete cached results and temporary files in `.sda-cache/`, `.journalism-cache/`, and `.tmp/`.
@@ -126,6 +128,10 @@ npm run cache-plot-docs
126
128
  ```
127
129
 
128
130
  This checks npm and skips generation if that version is already cached. To generate
129
- or refresh a specific version, run `npm run cache-plot-docs -- 0.6.17`.
131
+ or refresh a specific version, run `npm run cache-plot-docs -- 0.6.18`.
130
132
  Review and commit `docs-cache/observable-plot/<version>/llm.md`; keep earlier
131
133
  versions for pinned projects. The command fetches the tagged upstream pages and license.
134
+ Push the cache to `main` to make it available to documentation downloads; it is
135
+ served directly from GitHub rather than included in the npm package. Changes to
136
+ the downloader itself also need an npm release. Plot 0.6.18 uses the upstream tag
137
+ `v.0.6.18`, which the downloader handles explicitly.
package/dist/main.mjs CHANGED
@@ -179,12 +179,13 @@ function ensureReadme(runtime, installedPackages = []) {
179
179
  path: "README.md",
180
180
  name: "libraries",
181
181
  createContent: (section) => `# Data project\n\nCreated with [setup-data-project](https://github.com/nshiab/setup-data-project).\n\n${section}`,
182
- content: `${libraries ? `Installed libraries: ${libraries}.\n\n` : ""}Use sda/main.ts to process source data from sda/data/ and write results to sda/output/. Both data folders are ignored by Git. Put reusable helpers in sda/helpers/ and tests in sda/test/.
182
+ content: `${libraries ? `Installed libraries: ${libraries}.\n\n` : ""}Use sda/main.ts to process source data from sda/data/ and write results to sda/output/. Both data folders are ignored by Git. Put reusable helpers in sda/helpers/ and tests in sda/test/. Name test files \`*.test.ts\`.${runtime === "bun" ? " Use Bun 1.3.1 or newer to run checks before adding your first test." : ""}
183
183
 
184
184
  - \`${run} sda\`: run \`${run} fix\`, then run the analysis once if checks pass.
185
185
  - \`${run} sda:watch\`: do the same on changes to sda/ and .env, excluding sda/output/.
186
186
  - \`${run} sda:status\`: check whether an SDA run or watcher is active.
187
- - \`${run} all-tests\`: check formatting, lint, and TypeScript types. When adding tests, extend this script to run them after the existing checks.
187
+ - \`${run} sda:tests\`: check formatting, lint, and TypeScript types, then run the tests in sda/test/.
188
+ - \`${run} sda:tests:watch\`: rerun those checks and tests on changes to sda/, .env, and tsconfig.json, excluding sda/output/.
188
189
  - \`${run} fix\`: format files, apply automatic lint fixes, and check types.
189
190
  - \`${run} docs\`: refresh documentation for the installed library versions.
190
191
  - \`${run} clean\`: delete cached results and temporary files in .sda-cache/, .journalism-cache/, and .tmp/.
@@ -223,7 +224,7 @@ async function installPackages(packages, options = {}) {
223
224
  //#endregion
224
225
  //#region package.json
225
226
  var name = "@nshiab/setup-data-project";
226
- var version = "4.0.11";
227
+ var version = "4.0.13";
227
228
  //#endregion
228
229
  //#region src/helpers/ensureTooling.ts
229
230
  const tools = [
@@ -305,11 +306,13 @@ function getProjectTasks(runtime = getRuntime()) {
305
306
  const fmt = runtime === "bun" ? "bun run --bun oxfmt" : "oxfmt";
306
307
  const lint = `${runtime === "bun" ? "bun run --bun oxlint" : "oxlint"} --type-aware --type-check`;
307
308
  const runner = runtime === "bun" ? "bun run --bun --no-env-file sda-run" : "sda-run";
309
+ const tests = runtime === "bun" ? "bun test --pass-with-no-tests ./sda/test/" : "node --env-file-if-exists=.env --test \"sda/test/**/*.test.ts\"";
308
310
  return {
309
311
  sda: `${runner} sda/main.ts`,
310
312
  "sda:watch": `${runner} --watch sda/main.ts sda .env --ignore sda/output`,
311
313
  "sda:status": `${runner} --status`,
312
- "all-tests": `${fmt} --check && ${lint}`,
314
+ "sda:tests": `${fmt} --check && ${lint} && ${tests}`,
315
+ "sda:tests:watch": `${runner} --watch-tests sda .env tsconfig.json --ignore sda/output`,
313
316
  clean: `${runner} --clean`,
314
317
  fix: `${fmt} --write && ${lint} --fix --format default`,
315
318
  docs: `${runtime === "bun" ? "bun run --bun --no-env-file " : ""}setup-data-project --docs`
@@ -322,13 +325,16 @@ function createFolderStructure(selectedPackages) {
322
325
  const folders = [
323
326
  "data",
324
327
  "helpers",
325
- "output"
328
+ "output",
329
+ "test"
326
330
  ];
327
331
  if (!existsSync(sdaFolder)) mkdirSync(sdaFolder, { recursive: true });
328
332
  for (const folder of folders) {
329
333
  const path = join(sdaFolder, folder);
330
334
  if (!existsSync(path)) mkdirSync(path, { recursive: true });
331
335
  }
336
+ const gitkeep = join(sdaFolder, "test", ".gitkeep");
337
+ if (lstatSync(gitkeep, { throwIfNoEntry: false }) === void 0) writeFileSync(gitkeep, "");
332
338
  const mainTsPath = join(sdaFolder, "main.ts");
333
339
  let mainTsContent = "console.log(\"Hello simple-data-analysis!\");\n";
334
340
  if (selectedPackages.includes("@nshiab/simple-data-analysis") || selectedPackages.includes("@nshiab/simple-data-analysis-core")) mainTsContent = `import { SimpleDB } from "${selectedPackages.includes("@nshiab/simple-data-analysis") ? "@nshiab/simple-data-analysis" : "@nshiab/simple-data-analysis-core"}";
@@ -366,13 +372,13 @@ ${links.length ? `Documentation for these installed libraries is available local
366
372
 
367
373
  Use sda/main.ts as the entry point and sda/helpers/ for reusable helpers. Keep one function per helper file, with the file named after the function. Put source data in sda/data/ and results in sda/output/.
368
374
 
369
- Add focused tests for error-prone transformations, reusable logic with meaningful edge cases, and bug fixes. Mirror source paths under sda/test/: for example, sda/helpers/cleanRows.ts maps to sda/test/helpers/cleanRows.test.ts. Prefer the runtime's built-in test runner. When adding tests, extend the \`all-tests\` script to run them after the existing checks.
375
+ Add focused tests for error-prone transformations, reusable logic with meaningful edge cases, and bug fixes. Mirror source paths under sda/test/: for example, sda/helpers/cleanRows.ts maps to sda/test/helpers/cleanRows.test.ts. Prefer the runtime's built-in test runner.
370
376
 
371
377
  Run \`${run} sda\` to fix and check code, then execute the analysis once.
372
378
 
373
379
  The clean script removes cached results and temporary files. Run it only when those cached results can be discarded.
374
380
 
375
- Before handing off code changes, run \`${run} all-tests\` and resolve failures.`
381
+ Before handing off code changes, run \`${run} sda:tests\` and resolve failures.`
376
382
  });
377
383
  }
378
384
  //#endregion
@@ -534,10 +540,16 @@ function cleanPlotMarkdown(content) {
534
540
  return result.replace(/\uE000PLOT(\d+)\uE000/g, (_match, index) => preserved[Number(index)]) + "\n";
535
541
  }
536
542
  //#endregion
543
+ //#region src/helpers/getPlotTag.ts
544
+ function getPlotTag(version) {
545
+ return version === "0.6.18" ? `v.${version}` : `v${version}`;
546
+ }
547
+ //#endregion
537
548
  //#region src/helpers/combinePlotDocs.ts
538
549
  function combinePlotDocs(version, documents) {
539
550
  const pages = [...documents.keys()].sort();
540
- const source = `https://github.com/observablehq/plot/tree/v${version}/docs`;
551
+ const tag = getPlotTag(version);
552
+ const source = `https://github.com/observablehq/plot/tree/${tag}/docs`;
541
553
  const anchors = /* @__PURE__ */ new Map();
542
554
  const sections = /* @__PURE__ */ new Map();
543
555
  const pageId = (page) => `plot-${page.replace(/\.md$/, "").replaceAll("/", "--")}`;
@@ -583,10 +595,10 @@ function combinePlotDocs(version, documents) {
583
595
  return `${source}/${markdown}${fragment ? `#${fragment}` : ""}`;
584
596
  }
585
597
  if (resolved.endsWith(".md")) return `${source}/${resolved}${fragment ? `#${fragment}` : ""}`;
586
- const base = `https://raw.githubusercontent.com/observablehq/plot/refs/tags/v${version}/docs/`;
598
+ const base = `https://raw.githubusercontent.com/observablehq/plot/refs/tags/${tag}/docs/`;
587
599
  return path.startsWith("/") ? new URL(`public${target}`, base).href : new URL(target, `${base}${page}`).href;
588
600
  }
589
- return cleanPlotMarkdown(`# Observable Plot ${version}\n\nPackage: \`@observablehq/plot@${version}\`. Source: [v${version}](${source}).\n\nThis reference combines selected upstream documentation for static charts and maps. Introductory and site pages, interaction helpers, and the Auto and Tip marks are omitted. Website controls are omitted; upstream setup and interactive templates are labeled as reference code. Use the table of contents to find API signatures and examples; links to omitted pages lead to the tagged upstream documentation.\n\n## Table of contents\n\n${pages.flatMap((page) => [`- [${page}](#${pageId(page)})`, ...(sections.get(page) ?? []).map(({ title, id }) => ` - [${title.replace(/[[\]]/g, "")}](#${id})`)]).join("\n")}\n\n---\n\n${pages.map((page) => {
601
+ return cleanPlotMarkdown(`# Observable Plot ${version}\n\nPackage: \`@observablehq/plot@${version}\`. Source: [${tag}](${source}).\n\nThis reference combines selected upstream documentation for static charts and maps. Introductory and site pages, interaction helpers, and the Auto and Tip marks are omitted. Website controls are omitted; upstream setup and interactive templates are labeled as reference code. Use the table of contents to find API signatures and examples; links to omitted pages lead to the tagged upstream documentation.\n\n## Table of contents\n\n${pages.flatMap((page) => [`- [${page}](#${pageId(page)})`, ...(sections.get(page) ?? []).map(({ title, id }) => ` - [${title.replace(/[[\]]/g, "")}](#${id})`)]).join("\n")}\n\n---\n\n${pages.map((page) => {
590
602
  const headings = new Map((sections.get(page) ?? []).map((heading) => [heading.line, heading]));
591
603
  const body = proseLines(documents.get(page) ?? "", (line, number) => {
592
604
  const heading = headings.get(number);
@@ -675,7 +687,7 @@ function splitPlotDocs(reference, version) {
675
687
  const sections = [...reference.matchAll(/<a id="(plot-[^"]+)"><\/a>\n\n# ([^\n]+\.md)\n\nSource:\s+([^\s]+)\n\n/g)];
676
688
  const files = /* @__PURE__ */ new Map();
677
689
  const anchors = /* @__PURE__ */ new Map();
678
- const source = `https://github.com/observablehq/plot/tree/v${version}/docs`;
690
+ const source = `https://github.com/observablehq/plot/tree/${getPlotTag(version)}/docs`;
679
691
  const completion = `<!-- setup-data-project:observable-plot:${version}:complete -->`;
680
692
  if (!reference.trimEnd().endsWith(completion)) throw new Error("Incomplete Plot reference.");
681
693
  const end = reference.lastIndexOf(completion);
@@ -712,7 +724,7 @@ function splitPlotDocs(reference, version) {
712
724
  //#endregion
713
725
  //#region src/helpers/fetchPlotDocs.ts
714
726
  async function fetchPlotDocs(version, options = {}) {
715
- const tag = `v${version}`;
727
+ const tag = getPlotTag(version);
716
728
  const directory = join("docs", "observable-plot");
717
729
  try {
718
730
  let llm;
@@ -763,7 +775,7 @@ async function fetchPlotDocs(version, options = {}) {
763
775
  }
764
776
  async function generatePlotReference(version) {
765
777
  if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) throw new Error("An exact Plot version is required.");
766
- const tag = `v${version}`;
778
+ const tag = getPlotTag(version);
767
779
  const pages = PLOT_DOC_PAGES;
768
780
  const documents = /* @__PURE__ */ new Map();
769
781
  const failed = [];
@@ -786,9 +798,10 @@ async function generatePlotReference(version) {
786
798
  return combinePlotDocs(version, documents).replace(completion, `## Upstream license\n\n${license.trim()}\n\n${completion}`);
787
799
  }
788
800
  function isStoredReference(content, version) {
789
- const source = `https://github.com/observablehq/plot/tree/v${version}/docs`;
801
+ const tag = getPlotTag(version);
802
+ const source = `https://github.com/observablehq/plot/tree/${tag}/docs`;
790
803
  const metadata = content.split(/\n\s*\n/)[1]?.replace(/\s+/g, " ");
791
- if (!content.startsWith(`# Observable Plot ${version}\n\n`) || metadata !== `Package: \`@observablehq/plot@${version}\`. Source: [v${version}](${source}).` || !content.trimEnd().endsWith(`<!-- setup-data-project:observable-plot:${version}:complete -->`)) return false;
804
+ if (!content.startsWith(`# Observable Plot ${version}\n\n`) || metadata !== `Package: \`@observablehq/plot@${version}\`. Source: [${tag}](${source}).` || !content.trimEnd().endsWith(`<!-- setup-data-project:observable-plot:${version}:complete -->`)) return false;
792
805
  const sections = [...content.matchAll(/<a id="(plot-[^"]+)"><\/a>\n\n# ([^\n]+\.md)\n\nSource:\s+([^\s]+)\n\n/g)];
793
806
  if (sections.length !== PLOT_DOC_PAGES.length) return false;
794
807
  const found = /* @__PURE__ */ new Set();
package/dist/main.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.mjs","names":["process","metadata.name","metadata.version","process"],"sources":["../src/helpers/getRuntime.ts","../src/helpers/packageRegistry.ts","../src/helpers/packageOptions.ts","../src/helpers/gitignoreEntries.ts","../src/helpers/ensureGitignore.ts","../src/helpers/ensureManagedSection.ts","../src/helpers/ensureReadme.ts","../src/helpers/installPackages.ts","../package.json","../src/helpers/ensureTooling.ts","../src/helpers/ensureVscode.ts","../src/helpers/getProjectTasks.ts","../src/helpers/createFolderStructure.ts","../src/helpers/ensureEnvFile.ts","../src/helpers/ensureAgents.ts","../src/helpers/projectManifest.ts","../src/helpers/fetchPackageDocs.ts","../src/helpers/cleanPlotMarkdown.ts","../src/helpers/combinePlotDocs.ts","../src/helpers/plotDocPages.ts","../src/helpers/splitPlotDocs.ts","../src/helpers/fetchPlotDocs.ts","../src/helpers/syncPackageDocs.ts","../src/helpers/getInstalledPackageVersions.ts","../src/helpers/parseArguments.ts","../src/main.ts"],"sourcesContent":["import process from \"node:process\";\nexport type Runtime = \"node\" | \"bun\";\nexport function getRuntime(versions: { bun?: string; node?: string } = process.versions): Runtime {\n return versions.bun ? \"bun\" : \"node\";\n}\n","export interface PackageConfig {\n value: string;\n label: string;\n type: \"sda\" | \"journalism\" | \"other\";\n hint?: string;\n}\n\nexport const SUPPORTED_PACKAGES: PackageConfig[] = [\n {\n value: \"@nshiab/simple-data-analysis\",\n label: \"simple-data-analysis\",\n type: \"sda\",\n hint: \"All the core functionality, plus methods for dataviz, AI, Google sheets, etc.\",\n },\n {\n value: \"@nshiab/simple-data-analysis-core\",\n label: \"simple-data-analysis-core\",\n type: \"sda\",\n hint: \"No fluff. Great for constrained environments, like a cheap server.\",\n },\n {\n value: \"@nshiab/journalism-ai\",\n label: \"journalism-ai\",\n type: \"journalism\",\n hint: \"Easily use AI local models with Ollama or remote models with Gemini/Vertex.\",\n },\n {\n value: \"@nshiab/journalism-google\",\n label: \"journalism-google\",\n type: \"journalism\",\n hint: \"Push and retrieve data from Google Sheets, Google Bucket, and more.\",\n },\n {\n value: \"@nshiab/journalism-web-scraping\",\n label: \"journalism-web-scraping\",\n type: \"journalism\",\n hint: \"Retrieve data from Statistics Canada tables, HTML table, download files...\",\n },\n {\n value: \"@nshiab/journalism-finance\",\n label: \"journalism-finance\",\n type: \"journalism\",\n hint: \"Retrieve financial data, calculate Canadian mortgage payments and taxes...\",\n },\n {\n value: \"@nshiab/journalism-format\",\n label: \"journalism-format\",\n type: \"journalism\",\n hint: \"Easily format dates, numbers, currencies...\",\n },\n {\n value: \"@nshiab/journalism-climate\",\n label: \"journalism-climate\",\n type: \"journalism\",\n hint: \"Retrieve data from Environment Canada APIs and more.\",\n },\n {\n value: \"@nshiab/journalism-dataviz\",\n label: \"journalism-dataviz\",\n type: \"journalism\",\n hint: \"Render charts/maps with Observable Plot or directly in the terminal.\",\n },\n {\n value: \"@nshiab/journalism-geo\",\n label: \"journalism-geo\",\n type: \"journalism\",\n hint: \"Calculate distances, transform 2D coordinates to 3D, wrangle GeoTIFF files...\",\n },\n {\n value: \"@nshiab/journalism-statistics\",\n label: \"journalism-statistics\",\n type: \"journalism\",\n hint: \"Functions for statistical tests, clustering, random path generation...\",\n },\n {\n value: \"@nshiab/journalism-web\",\n label: \"journalism-web\",\n type: \"journalism\",\n hint: \"Web related functions, including downloading data as CSV, extracting ZIP files to URLs...\",\n },\n {\n value: \"@nshiab/journalism-extras\",\n label: \"journalism-extras\",\n type: \"journalism\",\n hint: \"Functions to zip/unzip, sleep, reencode files, create nested directories...\",\n },\n];\n\n// Plot is installed alongside charting libraries, but is not a setup menu option.\nexport const DOCUMENTED_PACKAGES: PackageConfig[] = [\n ...SUPPORTED_PACKAGES,\n { value: \"@nshiab/journalism\", label: \"journalism\", type: \"journalism\" },\n { value: \"@observablehq/plot\", label: \"Observable Plot\", type: \"other\" },\n];\n\nexport function getInstalledPackageConfigs(installedPackages: string[]): PackageConfig[] {\n const installedSet = new Set(installedPackages);\n return DOCUMENTED_PACKAGES.filter((pkg) => installedSet.has(pkg.value));\n}\n","import { SUPPORTED_PACKAGES } from \"./packageRegistry.ts\";\n\nexport const PACKAGE_OPTIONS = SUPPORTED_PACKAGES.map((pkg) => ({\n value: pkg.value,\n label: pkg.label,\n hint: pkg.hint,\n}));\n","export const GITIGNORE_ENTRIES = [\n \"node_modules\",\n \"docs/\",\n \".tmp\",\n \".sda-cache\",\n \".journalism-cache\",\n \"sda/data\",\n \"sda/output\",\n \".env\",\n \".DS_Store\",\n];\n","import { lstatSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { GITIGNORE_ENTRIES } from \"./gitignoreEntries.ts\";\n\nexport const GITIGNORE_SENTINEL = \"# Added by setup-data-project. Do not remove this line.\";\n\nexport function ensureGitignore() {\n const path = \".gitignore\";\n const stats = lstatSync(path, { throwIfNoEntry: false });\n\n if (stats?.isSymbolicLink()) {\n return;\n }\n\n const content = stats === undefined ? \"\" : readFileSync(path, \"utf-8\");\n const hasSentinel = content.split(\"\\n\").some((line) => line.trim() === GITIGNORE_SENTINEL);\n\n if (hasSentinel) {\n const entries = new Set(content.split(\"\\n\").map((line) => line.trim()));\n const missing = GITIGNORE_ENTRIES.filter((entry) => !entries.has(entry));\n if (missing.length)\n writeFileSync(\n path,\n content + (content.endsWith(\"\\n\") ? \"\" : \"\\n\") + missing.join(\"\\n\") + \"\\n\",\n );\n return;\n }\n\n const separator = content === \"\" ? \"\" : content.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n const block = `${GITIGNORE_SENTINEL}\\n${GITIGNORE_ENTRIES.join(\"\\n\")}\\n`;\n writeFileSync(path, content + separator + block);\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\n\ninterface ManagedSectionOptions {\n path: string;\n name: string;\n content: string;\n createContent: (section: string) => string;\n}\n\nexport function ensureManagedSection(\n options: ManagedSectionOptions,\n): \"created\" | \"updated\" | \"unchanged\" | \"missing-markers\" {\n const startMarker = `<!-- setup-data-project:${options.name}:start / Safe to remove if you don't want this generated section. -->`;\n const endMarker = `<!-- setup-data-project:${options.name}:end / End of generated section. -->`;\n const trimmedContent = options.content.trim();\n const section =\n trimmedContent === \"\"\n ? `${startMarker}\\n${endMarker}`\n : `${startMarker}\\n\\n${trimmedContent}\\n\\n${endMarker}`;\n\n if (!existsSync(options.path)) {\n writeFileSync(options.path, ensureFinalNewline(options.createContent(section)));\n return \"created\";\n }\n\n const currentContent = readFileSync(options.path, \"utf-8\");\n const start = new RegExp(\n `<!-- setup-data-project:${options.name}:start(?: / [^\\\\r\\\\n]*?)? -->`,\n ).exec(currentContent);\n const end = new RegExp(`<!-- setup-data-project:${options.name}:end(?: / [^\\\\r\\\\n]*?)? -->`).exec(\n currentContent,\n );\n\n if (!start || !end || end.index < start.index + start[0].length) {\n return \"missing-markers\";\n }\n\n const nextContent =\n currentContent.slice(0, start.index) +\n section +\n currentContent.slice(end.index + end[0].length);\n\n if (nextContent === currentContent) {\n return \"unchanged\";\n }\n\n writeFileSync(options.path, ensureFinalNewline(nextContent));\n return \"updated\";\n}\n\nfunction ensureFinalNewline(content: string): string {\n return content.endsWith(\"\\n\") ? content : content + \"\\n\";\n}\n","import { ensureManagedSection } from \"./ensureManagedSection.ts\";\nimport { getInstalledPackageConfigs } from \"./packageRegistry.ts\";\nimport type { Runtime } from \"./getRuntime.ts\";\nexport function ensureReadme(runtime: Runtime, installedPackages: string[] = []) {\n const run = runtime === \"bun\" ? \"bun run\" : \"npm run\";\n const libraries = getInstalledPackageConfigs(installedPackages)\n .map((pkg) => `\\`${pkg.value}\\``)\n .join(\", \");\n ensureManagedSection({\n path: \"README.md\",\n name: \"libraries\",\n createContent: (section) =>\n `# Data project\\n\\nCreated with [setup-data-project](https://github.com/nshiab/setup-data-project).\\n\\n${section}`,\n content: `${libraries ? `Installed libraries: ${libraries}.\\n\\n` : \"\"}Use sda/main.ts to process source data from sda/data/ and write results to sda/output/. Both data folders are ignored by Git. Put reusable helpers in sda/helpers/ and tests in sda/test/.\n\n- \\`${run} sda\\`: run \\`${run} fix\\`, then run the analysis once if checks pass.\n- \\`${run} sda:watch\\`: do the same on changes to sda/ and .env, excluding sda/output/.\n- \\`${run} sda:status\\`: check whether an SDA run or watcher is active.\n- \\`${run} all-tests\\`: check formatting, lint, and TypeScript types. When adding tests, extend this script to run them after the existing checks.\n- \\`${run} fix\\`: format files, apply automatic lint fixes, and check types.\n- \\`${run} docs\\`: refresh documentation for the installed library versions.\n- \\`${run} clean\\`: delete cached results and temporary files in .sda-cache/, .journalism-cache/, and .tmp/.\n\nSDA blocks simultaneous runs. Recovery after a forced termination is best effort.\nLock records live in .sda-cache/lock/. The clean command preserves that directory and its parent so an active run keeps its lock.\n\nIn VS Code, install the recommended Oxc extension for formatting and linting. Generated .vscode/settings.json enables formatting and lint fixes on save, plus visual line wrapping. Existing VS Code configuration files are preserved.\n\nThe generated docs/ folder is ignored by Git. Refresh it after cloning or updating dependencies. See AGENTS.md for documentation pointers.`,\n });\n}\n","import { execFile } from \"node:child_process\";\nimport { getRuntime } from \"./getRuntime.ts\";\nexport function runPackageManager(args: string[]): Promise<void> {\n const command = getRuntime() === \"bun\" ? \"bun\" : process.platform === \"win32\" ? \"npm.cmd\" : \"npm\";\n return new Promise((resolve, reject) => {\n execFile(\n command,\n args,\n { maxBuffer: 10 * 1024 * 1024, shell: process.platform === \"win32\" },\n (error, stdout, stderr) => {\n if (error)\n reject(\n new Error(`${command} ${args.join(\" \")} failed.\\n${stderr || stdout}`, {\n cause: error,\n }),\n );\n else resolve();\n },\n );\n });\n}\nexport async function installPackages(\n packages: string[],\n options: { development?: boolean } = {},\n): Promise<void> {\n if (packages.length === 0) return;\n const bun = getRuntime() === \"bun\";\n await runPackageManager([\n bun ? \"add\" : \"install\",\n ...(options.development ? (bun ? [\"--dev\"] : [\"--save-dev\"]) : []),\n ...packages,\n ]);\n}\n","","import { existsSync, writeFileSync } from \"node:fs\";\nimport { ProjectManifest } from \"./projectManifest.ts\";\nimport { getRuntime } from \"./getRuntime.ts\";\nimport { installPackages } from \"./installPackages.ts\";\nimport metadata from \"../../package.json\" with { type: \"json\" };\nconst tools = [\"oxfmt\", \"oxlint\", \"oxlint-tsgolint\", \"@types/node\"];\nexport async function ensureTooling(manifest: ProjectManifest): Promise<void> {\n const runtime = getRuntime();\n const runtimeTools = runtime === \"bun\" ? [...tools, \"@types/bun\"] : tools;\n const installed = manifest.getInstalledPackages();\n await installPackages(\n [\n ...runtimeTools.filter((pkg) => !installed.includes(pkg)).map((pkg) => `${pkg}@latest`),\n ...(installed.includes(metadata.name) ? [] : [`${metadata.name}@${metadata.version}`]),\n ],\n { development: true },\n );\n if (\n ![\".oxlintrc.json\", \".oxlintrc.jsonc\", \"oxlint.config.ts\", \"oxlint.config.mts\"].some((file) =>\n existsSync(file),\n )\n ) {\n writeFileSync(\n \".oxlintrc.json\",\n `{\n \"options\": { \"typeAware\": true, \"typeCheck\": true }\n}\n`,\n );\n }\n if (\n [\".oxfmtrc.json\", \".oxfmtrc.jsonc\", \"oxfmt.config.ts\", \"oxfmt.config.mts\"].every(\n (file) => !existsSync(file),\n )\n )\n writeFileSync(\n \".oxfmtrc.json\",\n `{\n \"ignorePatterns\": [\"docs/**\", \"sda/data/**\", \"sda/output/**\"]\n}\n`,\n );\n if (!existsSync(\"tsconfig.json\"))\n writeFileSync(\n \"tsconfig.json\",\n `{\n \"compilerOptions\": {\n \"target\": \"ES2023\",\n \"module\": \"NodeNext\",\n \"strict\": true,\n \"noEmit\": true,\n \"allowImportingTsExtensions\": true,\n \"erasableSyntaxOnly\": ${runtime === \"node\"},\n \"types\": ${runtime === \"bun\" ? '[\"node\", \"bun\"]' : '[\"node\"]'},\n \"skipLibCheck\": true\n },\n \"include\": [\"sda/**/*.ts\"]\n}\n`,\n );\n}\n","import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\n\nexport function ensureVscode(): void {\n mkdirSync(\".vscode\", { recursive: true });\n const formatter = \"oxc.oxc-vscode\";\n const files = {\n \"extensions.json\": `{\n \"recommendations\": [\"oxc.oxc-vscode\"]\n}\n`,\n \"settings.json\": `${JSON.stringify(\n {\n \"editor.defaultFormatter\": formatter,\n \"[javascript]\": { \"editor.defaultFormatter\": formatter },\n \"[javascriptreact]\": { \"editor.defaultFormatter\": formatter },\n \"[typescript]\": { \"editor.defaultFormatter\": formatter },\n \"[typescriptreact]\": { \"editor.defaultFormatter\": formatter },\n \"oxc.disableNestedConfig\": true,\n \"oxc.fmt.disableNestedConfig\": true,\n \"editor.formatOnSave\": true,\n \"editor.formatOnSaveMode\": \"file\",\n \"editor.codeActionsOnSave\": { \"source.fixAll.oxc\": \"explicit\" },\n \"editor.wordWrap\": \"on\",\n },\n null,\n 2,\n )}\\n`,\n };\n for (const [name, config] of Object.entries(files)) {\n const path = `.vscode/${name}`;\n if (!existsSync(path)) writeFileSync(path, config);\n }\n}\n","import { getRuntime, type Runtime } from \"./getRuntime.ts\";\nexport function getProjectTasks(runtime: Runtime = getRuntime()) {\n const fmt = runtime === \"bun\" ? \"bun run --bun oxfmt\" : \"oxfmt\";\n const lint = `${runtime === \"bun\" ? \"bun run --bun oxlint\" : \"oxlint\"} --type-aware --type-check`;\n const runner = runtime === \"bun\" ? \"bun run --bun --no-env-file sda-run\" : \"sda-run\";\n return {\n sda: `${runner} sda/main.ts`,\n \"sda:watch\": `${runner} --watch sda/main.ts sda .env --ignore sda/output`,\n \"sda:status\": `${runner} --status`,\n \"all-tests\": `${fmt} --check && ${lint}`,\n clean: `${runner} --clean`,\n fix: `${fmt} --write && ${lint} --fix --format default`,\n docs: `${runtime === \"bun\" ? \"bun run --bun --no-env-file \" : \"\"}setup-data-project --docs`,\n };\n}\n","import { existsSync, lstatSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport function createFolderStructure(selectedPackages: string[]) {\n const sdaFolder = \"sda\";\n const folders = [\"data\", \"helpers\", \"output\"];\n\n if (!existsSync(sdaFolder)) {\n mkdirSync(sdaFolder, { recursive: true });\n }\n\n for (const folder of folders) {\n const path = join(sdaFolder, folder);\n if (!existsSync(path)) {\n mkdirSync(path, { recursive: true });\n }\n }\n\n const mainTsPath = join(sdaFolder, \"main.ts\");\n\n let mainTsContent = 'console.log(\"Hello simple-data-analysis!\");\\n';\n\n if (\n selectedPackages.includes(\"@nshiab/simple-data-analysis\") ||\n selectedPackages.includes(\"@nshiab/simple-data-analysis-core\")\n ) {\n const pkg = selectedPackages.includes(\"@nshiab/simple-data-analysis\")\n ? \"@nshiab/simple-data-analysis\"\n : \"@nshiab/simple-data-analysis-core\";\n mainTsContent = `import { SimpleDB } from \"${pkg}\";\n\nconst sdb = new SimpleDB();\nconst table = sdb.newTable();\n\nawait table.loadArray([{ message: \"Hello simple-data-analysis!\" }]).log();\n\nawait sdb.close();\n`;\n }\n\n if (lstatSync(mainTsPath, { throwIfNoEntry: false }) === undefined) {\n writeFileSync(mainTsPath, mainTsContent);\n }\n\n return sdaFolder;\n}\n","import { lstatSync, writeFileSync } from \"node:fs\";\n\nexport function ensureEnvFile() {\n if (lstatSync(\".env\", { throwIfNoEntry: false }) === undefined) {\n writeFileSync(\".env\", \"\");\n }\n}\n","import type { PackageDocs } from \"./fetchPackageDocs.ts\";\nimport { ensureManagedSection } from \"./ensureManagedSection.ts\";\nimport { getInstalledPackageConfigs } from \"./packageRegistry.ts\";\nimport type { Runtime } from \"./getRuntime.ts\";\nexport function ensureAgents(\n docsMapping: Record<string, PackageDocs>,\n runtime: Runtime,\n installedPackages: string[] = Object.keys(docsMapping),\n) {\n const run = runtime === \"bun\" ? \"bun run\" : \"npm run\";\n const links = getInstalledPackageConfigs(installedPackages).map((pkg) => {\n if (pkg.value === \"@observablehq/plot\")\n return `- Observable Plot charts and maps: start at \\`docs/observable-plot/llms.txt\\`, then read the relevant pages for use with writeChart and writeMap.`;\n return `- \\`${pkg.value}\\`: start at \\`docs/${pkg.value.slice(\"@nshiab/\".length)}/llms.txt\\`, then read the relevant API pages and examples.`;\n });\n ensureManagedSection({\n path: \"AGENTS.md\",\n name: \"agents\",\n createContent: (section) => section,\n content: `Read README.md for project guidance and package.json for the installed libraries and scripts. Use the installed libraries. Ask the user before adding a dependency.\n\n${links.length ? `Documentation for these installed libraries is available locally:\\n\\n${links.join(\"\\n\")}\\n\\n` : \"\"}Before making changes or running project commands, run \\`${run} sda:status\\` and follow its instructions.\n\nUse sda/main.ts as the entry point and sda/helpers/ for reusable helpers. Keep one function per helper file, with the file named after the function. Put source data in sda/data/ and results in sda/output/.\n\nAdd focused tests for error-prone transformations, reusable logic with meaningful edge cases, and bug fixes. Mirror source paths under sda/test/: for example, sda/helpers/cleanRows.ts maps to sda/test/helpers/cleanRows.test.ts. Prefer the runtime's built-in test runner. When adding tests, extend the \\`all-tests\\` script to run them after the existing checks.\n\nRun \\`${run} sda\\` to fix and check code, then execute the analysis once.\n\nThe clean script removes cached results and temporary files. Run it only when those cached results can be discarded.\n\nBefore handing off code changes, run \\`${run} all-tests\\` and resolve failures.`,\n });\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { isObject } from \"./jsonObject.ts\";\nexport class ProjectManifest {\n #config: Record<string, unknown>;\n private constructor(config: Record<string, unknown>) {\n this.#config = config;\n }\n static open(): ProjectManifest {\n if (!existsSync(\"package.json\"))\n return new ProjectManifest({ name: \"data-project\", private: true, type: \"module\" });\n const config: unknown = JSON.parse(readFileSync(\"package.json\", \"utf8\"));\n if (!isObject(config)) throw new Error(\"package.json must contain a JSON object.\");\n return new ProjectManifest(config);\n }\n reload(): void {\n this.#config = ProjectManifest.open().#config;\n }\n getInstalledPackages(): string[] {\n return Object.keys(this.getInstalledPackageSpecifiers());\n }\n getInstalledPackageSpecifiers(): Record<string, string> {\n const packages: Record<string, string> = {};\n for (const key of [\"dependencies\", \"devDependencies\"]) {\n const dependencies = this.#config[key];\n if (isObject(dependencies))\n for (const [name, version] of Object.entries(dependencies)) {\n if (typeof version === \"string\") packages[name] = version;\n }\n }\n return packages;\n }\n updateTasks(tasks: Record<string, string>): void {\n if (this.#config.type === \"commonjs\") {\n throw new Error(\n 'Setup requires an ESM project. Set \"type\": \"module\" in package.json, or use --docs to refresh documentation only.',\n );\n }\n if (this.#config.type === undefined) this.#config.type = \"module\";\n const existing = this.#config.scripts;\n this.#config.scripts = { ...tasks, ...(isObject(existing) ? existing : {}) };\n writeFileSync(\"package.json\", JSON.stringify(this.#config, null, 2) + \"\\n\");\n }\n}\n","import { log } from \"@clack/prompts\";\nimport {\n existsSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { join, posix } from \"node:path\";\nimport { x } from \"tar\";\nimport { DOCUMENTED_PACKAGES } from \"./packageRegistry.ts\";\nexport interface PackageDocs {\n readme?: string;\n index?: string;\n llm?: string;\n plot?: { version: string; pages: string[] };\n}\nexport async function fetchPackageDocs(pkg: string, version: string): Promise<PackageDocs> {\n const config = DOCUMENTED_PACKAGES.find(\n (item) => item.value === pkg && item.value.startsWith(\"@nshiab/\"),\n );\n if (!config || !/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/.test(version))\n throw new Error(`Unsupported package or version: ${pkg}@${version}`);\n const repo = pkg.slice(\"@nshiab/\".length);\n mkdirSync(\"docs\", { recursive: true });\n const staging = mkdtempSync(join(\"docs\", \".download-\"));\n const contents = join(staging, \"contents\");\n const target = join(\"docs\", repo);\n const backup = join(staging, \"previous\");\n try {\n const url = `https://github.com/nshiab/${repo}/releases/download/v${version}/documentation.tar.gz`;\n const response = await fetch(url);\n if (!response.ok) throw new Error(`HTTP ${response.status} from ${url}`);\n const archive = join(staging, \"documentation.tar.gz\");\n writeFileSync(archive, Buffer.from(await response.arrayBuffer()));\n mkdirSync(contents);\n let unsafeEntry: string | undefined;\n await x({\n file: archive,\n cwd: contents,\n strict: true,\n preservePaths: false,\n filter(path, entry) {\n const normalized = posix.normalize(path);\n if (\n path.includes(\"\\\\\") ||\n path.startsWith(\"/\") ||\n normalized === \"..\" ||\n normalized.startsWith(\"../\") ||\n !(\"type\" in entry) ||\n ![\"File\", \"Directory\"].includes(entry.type)\n ) {\n unsafeEntry = path;\n return false;\n }\n return true;\n },\n });\n if (unsafeEntry !== undefined) throw new Error(`Unsafe archive entry: ${unsafeEntry}`);\n for (const path of [\"README.md\", \"LICENSE\", \"llms.txt\", \"docs\"]) {\n if (!existsSync(join(contents, path)))\n throw new Error(`Documentation archive is missing ${path}.`);\n }\n const readme = readFileSync(join(contents, \"README.md\"), \"utf8\");\n const index = readFileSync(join(contents, \"llms.txt\"), \"utf8\");\n if (existsSync(target)) renameSync(target, backup);\n try {\n renameSync(contents, target);\n } catch (error) {\n if (existsSync(backup)) renameSync(backup, target);\n throw error;\n }\n return { readme, index };\n } catch (error) {\n log.warn(\n `Could not refresh ${pkg}@${version}: ${String(error)} Existing documentation was preserved and may be stale. Run the docs script again after resolving the error.`,\n );\n return {};\n } finally {\n rmSync(staging, { recursive: true, force: true });\n }\n}\n","// Plot's source is VitePress Markdown. Keep examples as reference material,\n// but remove the website UI and turn its custom containers into ordinary text.\nexport function cleanPlotMarkdown(content: string): string {\n const preserved: string[] = [];\n const keep = (value: string) => {\n preserved.push(value);\n return `\\uE000PLOT${preserved.length - 1}\\uE000`;\n };\n const lines = content.split(\"\\n\");\n const prose: string[] = [];\n for (let index = 0; index < lines.length; index++) {\n if (/^\\s*<!--/.test(lines[index])) {\n const start = index;\n while (!lines[index].includes(\"-->\") && index + 1 < lines.length) index++;\n prose.push(lines.slice(start, index + 1).join(\"\\n\"));\n continue;\n }\n const opening = lines[index].match(/^ {0,3}(`{3,}|~{3,})(.*)$/);\n if (!opening) {\n prose.push(lines[index]);\n continue;\n }\n const start = index;\n while (++index < lines.length) {\n const closing = lines[index].match(/^ {0,3}(`{3,}|~{3,})\\s*$/);\n if (closing?.[1][0] === opening[1][0] && closing[1].length >= opening[1].length) break;\n }\n if (index >= lines.length) throw new Error(\"Unclosed Plot code fence.\");\n const block = lines.slice(start, index + 1);\n if (opening[2].trim() === \"js-vue\") {\n block[0] = `${opening[1]}text`;\n prose.push(\n keep(\n \"Interactive example template (values in `{{…}}` come from the upstream website):\\n\\n\" +\n block.join(\"\\n\"),\n ),\n );\n } else {\n prose.push(keep(block.join(\"\\n\")));\n }\n }\n let result = prose\n .join(\"\\n\")\n .replace(/<script\\b[^>]*>([\\s\\S]*?)<\\/script>/g, (_match: string, code: string) => {\n const fence = \"`\".repeat(\n Math.max(3, ...[...code.matchAll(/`+/g)].map((match) => match[0].length + 1)),\n );\n return keep(\n `**Upstream example setup.** This code may use Vue and sample data from the linked source page.\\n\\n${fence}js\\n${code.trim()}\\n${fence}`,\n );\n })\n .replace(/^[ \\t]*<!--(?!\\s*setup-data-project:)[\\s\\S]*?-->/gm, \"\")\n .replace(\n /<\\/?[A-Za-z](?:\"[^\"]*\"|'[^']*'|[^'\"><])*>|(`+)[^`\\n]*?\\1/g,\n (part: string, fence: string | undefined) => (fence ? keep(part) : part),\n )\n .replace(/<style\\b[^>]*>[\\s\\S]*?<\\/style>/g, \"\")\n .replace(/<p\\b[^>]*>([\\s\\S]*?)<\\/p>/g, (_match: string, body: string) =>\n /<(?:input|select|label)\\b/.test(body) ? \"\" : body,\n )\n .replace(/<PlotRender\\b[\\s\\S]*?\\/>/g, (component) => {\n const options = component.match(/:options=([\"'])([\\s\\S]*?)\\1/)?.[2];\n const method = component.match(/\\bmethod=[\"'](\\w+)[\"']/)?.[1] ?? \"plot\";\n if (!options) throw new Error(\"Unrecognized PlotRender example.\");\n return keep(`\\`\\`\\`js\\nPlot.${method}(${options});\\n\\`\\`\\``);\n })\n .replace(/<VersionBadge\\b[\\s\\S]*?\\/>/g, (badge) => {\n const version = badge.match(/\\bversion=[\"']([^\"']+)[\"']/)?.[1];\n return version ? `(since v${version})` : \"\";\n })\n .replace(/<\\/?span\\b(?:\"[^\"]*\"|'[^']*'|[^'\">])*>/g, \"\")\n .replace(/<svg\\b[\\s\\S]*?<\\/svg>/g, \"arrow\");\n result = result\n .replace(/^[ \\t]*:::plot\\b([^\\n]*)/gm, (_match: string, options: string) => {\n const url = options.match(/https?:\\/\\/\\S+/)?.[0];\n return url ? `[Interactive example](${url})\\n` : \"\";\n })\n .replace(\n /^([ \\t]*):::(tip|info|warning)\\b[ \\t]*/gm,\n (_match: string, indent: string, kind: string) =>\n `${indent}**${kind[0].toUpperCase() + kind.slice(1)}:** `,\n )\n .replace(/^[ \\t]*:::[ \\t]*$/gm, \"\")\n .replace(/[ \\t]+:::[ \\t]*$/gm, \"\")\n .replace(\n /\\{\\{([\\s\\S]*?)\\}\\}/g,\n (_match: string, expression: string) => `\\`${expression.trim().replace(/\\s+/g, \" \")}\\``,\n )\n .replace(/[ \\t]+$/gm, \"\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .trim();\n return (\n result.replace(\n /\\uE000PLOT(\\d+)\\uE000/g,\n (_match: string, index: string) => preserved[Number(index)],\n ) + \"\\n\"\n );\n}\n","import { cleanPlotMarkdown } from \"./cleanPlotMarkdown.ts\";\nimport { posix } from \"node:path\";\n\n// The Plot source uses ATX headings, explicit VitePress IDs, and Markdown fences.\n// Keep code verbatim; rewrite only prose links and anchors while joining pages.\nexport function combinePlotDocs(version: string, documents: Map<string, string>): string {\n const pages = [...documents.keys()].sort();\n const source = `https://github.com/observablehq/plot/tree/v${version}/docs`;\n const anchors = new Map<string, Map<string, string>>();\n const sections = new Map<string, { line: number; title: string; id: string }[]>();\n const pageId = (page: string) => `plot-${page.replace(/\\.md$/, \"\").replaceAll(\"/\", \"--\")}`;\n\n for (const page of pages) {\n const ids = new Map<string, string>();\n const headings: { line: number; title: string; id: string }[] = [];\n const counts = new Map<string, number>();\n proseLines(documents.get(page) ?? \"\", (line, number) => {\n for (const match of line.matchAll(/\\bid=[\"']([^\"']+)[\"']/g)) {\n ids.set(match[1], `${pageId(page)}--${match[1]}`);\n }\n const heading = line.match(/^ {0,3}#{1,6}\\s+(.+?)\\s*#*\\s*$/);\n if (!heading) return line;\n const explicit = heading[1].match(/\\{#([^}]+)\\}/)?.[1];\n const title = heading[1].replace(/\\s*\\{#[^}]+\\}/g, \"\");\n const slug =\n explicit ??\n title\n .replace(/<[^>]*>/g, \"\")\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}_\\s-]/gu, \"\")\n .trim()\n .replace(/\\s+/g, \"-\");\n const count = counts.get(slug) ?? 0;\n counts.set(slug, count + 1);\n const localId = `${slug}${count ? `-${count}` : \"\"}`;\n const id = `${pageId(page)}--${localId}`;\n ids.set(localId, id);\n headings.push({ line: number, title, id });\n return line;\n });\n anchors.set(page, ids);\n sections.set(page, headings);\n }\n\n function link(target: string, page: string): string {\n if (/^(?:[a-z][a-z\\d+.-]*:|\\/\\/)/i.test(target)) return target;\n const [pathAndQuery, fragment] = target.split(\"#\", 2);\n const path = pathAndQuery.split(\"?\", 1)[0];\n const resolved =\n path === \"\"\n ? page\n : posix.normalize(\n path.startsWith(\"/\") ? path.slice(1) : posix.join(posix.dirname(page), path),\n );\n const markdown = [resolved, `${resolved}.md`, `${resolved}/index.md`].find((candidate) =>\n documents.has(candidate),\n );\n if (markdown) {\n const id = fragment\n ? anchors.get(markdown)?.get(decodeURIComponent(fragment))\n : pageId(markdown);\n if (id) return `#${id}`;\n // Preserve an upstream target when a fragment is not a known heading/ID.\n return `${source}/${markdown}${fragment ? `#${fragment}` : \"\"}`;\n }\n if (resolved.endsWith(\".md\")) {\n return `${source}/${resolved}${fragment ? `#${fragment}` : \"\"}`;\n }\n const base =\n \"https://raw.githubusercontent.com/observablehq/plot/\" + `refs/tags/v${version}/docs/`;\n return path.startsWith(\"/\")\n ? new URL(`public${target}`, base).href\n : new URL(target, `${base}${page}`).href;\n }\n\n const contents = pages\n .flatMap((page) => [\n `- [${page}](#${pageId(page)})`,\n ...(sections.get(page) ?? []).map(\n ({ title, id }) => ` - [${title.replace(/[[\\]]/g, \"\")}](#${id})`,\n ),\n ])\n .join(\"\\n\");\n const combined = pages\n .map((page) => {\n const headings = new Map(\n (sections.get(page) ?? []).map((heading) => [heading.line, heading]),\n );\n const body = proseLines(documents.get(page) ?? \"\", (line, number) => {\n const heading = headings.get(number);\n // Inline code also remains verbatim. Plot's prose links have simple destinations.\n line = line\n .split(/(`+[^`]*`+)/g)\n .map((part, index) => {\n if (index % 2) return part;\n return part\n .replace(\n /(\\]\\()([^\\s)]+)([^)]*\\))/g,\n (_match: string, before: string, target: string, after: string) =>\n `${before}${link(target, page)}${after}`,\n )\n .replace(\n /^( {0,3}\\[[^\\]]+\\]:\\s*)(\\S+)/,\n (_match: string, before: string, target: string) =>\n `${before}${link(target, page)}`,\n )\n .replace(\n /(?<!:)\\b(href|src)=([\"'])([^\"']+)\\2/g,\n (_match: string, attr: string, quote: string, target: string) =>\n `${attr}=${quote}${link(target, page)}${quote}`,\n )\n .replace(\n /\\bid=([\"'])([^\"']+)\\1/g,\n (_match: string, quote: string, id: string) =>\n `id=${quote}${anchors.get(page)?.get(id) ?? id}${quote}`,\n );\n })\n .join(\"\");\n return heading\n ? `<a id=\"${heading.id}\"></a>\\n\\n${line.replace(/\\s*\\{#[^}]+\\}/g, \"\")}`\n : line;\n });\n return `<a id=\"${pageId(page)}\"></a>\\n\\n# ${page}\\n\\nSource: ${source}/${page}\\n\\n${body}`;\n })\n .join(\"\\n\\n---\\n\\n\");\n return cleanPlotMarkdown(\n `# Observable Plot ${version}\\n\\nPackage: \\`@observablehq/plot@${version}\\`. Source: [v${version}](${source}).\\n\\nThis reference combines selected upstream documentation for static charts and maps. Introductory and site pages, interaction helpers, and the Auto and Tip marks are omitted. Website controls are omitted; upstream setup and interactive templates are labeled as reference code. Use the table of contents to find API signatures and examples; links to omitted pages lead to the tagged upstream documentation.\\n\\n## Table of contents\\n\\n${contents}\\n\\n---\\n\\n${combined}\\n\\n<!-- setup-data-project:observable-plot:${version}:complete -->\\n`,\n );\n}\n\nexport function proseLines(\n content: string,\n transform: (line: string, number: number) => string,\n): string {\n let fence: { character: string; length: number } | undefined;\n let script = false;\n return content\n .split(\"\\n\")\n .map((line, number) => {\n const marker = line.match(/^ {0,3}(`{3,}|~{3,})/);\n if (fence) {\n if (\n marker?.[1][0] === fence.character &&\n marker[1].length >= fence.length &&\n /^ {0,3}(?:`+|~+)\\s*$/.test(line)\n )\n fence = undefined;\n return line;\n }\n if (marker) {\n fence = { character: marker[1][0], length: marker[1].length };\n return line;\n }\n if (/^\\s*<script\\b/.test(line)) script = true;\n if (script) {\n if (/<\\/script>/.test(line)) script = false;\n return line;\n }\n return transform(line, number);\n })\n .join(\"\\n\");\n}\n","// Static chart creation references. Keep this explicit so new upstream pages do\n// not silently expand the installed agent reference.\nexport const PLOT_DOC_PAGES: string[] = [\n \"features/plots.md\",\n \"features/marks.md\",\n \"features/scales.md\",\n \"features/projections.md\",\n \"features/legends.md\",\n \"features/facets.md\",\n \"features/formats.md\",\n \"features/curves.md\",\n \"transforms/bin.md\",\n \"transforms/group.md\",\n \"transforms/stack.md\",\n \"transforms/normalize.md\",\n \"transforms/centroid.md\",\n \"transforms/sort.md\",\n \"marks/area.md\",\n \"marks/arrow.md\",\n \"marks/axis.md\",\n \"marks/bar.md\",\n \"marks/bollinger.md\",\n \"marks/box.md\",\n \"marks/cell.md\",\n \"marks/contour.md\",\n \"marks/delaunay.md\",\n \"marks/density.md\",\n \"marks/difference.md\",\n \"marks/dot.md\",\n \"marks/frame.md\",\n \"marks/geo.md\",\n \"marks/grid.md\",\n \"marks/hexgrid.md\",\n \"marks/image.md\",\n \"marks/line.md\",\n \"marks/linear-regression.md\",\n \"marks/link.md\",\n \"marks/raster.md\",\n \"marks/rect.md\",\n \"marks/rule.md\",\n \"marks/text.md\",\n \"marks/tick.md\",\n \"marks/tree.md\",\n \"marks/vector.md\",\n \"marks/waffle.md\",\n].sort();\n","import { cleanPlotMarkdown } from \"./cleanPlotMarkdown.ts\";\nimport { posix } from \"node:path\";\nimport { proseLines } from \"./combinePlotDocs.ts\";\nimport { PLOT_DOC_PAGES } from \"./plotDocPages.ts\";\n\n// Split the cached format without changing code examples or heading anchors.\nexport function splitPlotDocs(reference: string, version: string): Map<string, string> {\n const sections = [\n ...reference.matchAll(\n /<a id=\"(plot-[^\"]+)\"><\\/a>\\n\\n# ([^\\n]+\\.md)\\n\\nSource:\\s+([^\\s]+)\\n\\n/g,\n ),\n ];\n const files = new Map<string, string>();\n const anchors = new Map<string, string>();\n const source = `https://github.com/observablehq/plot/tree/v${version}/docs`;\n const completion = `<!-- setup-data-project:observable-plot:${version}:complete -->`;\n if (!reference.trimEnd().endsWith(completion)) throw new Error(\"Incomplete Plot reference.\");\n const end = reference.lastIndexOf(completion);\n const licenseStart = reference.lastIndexOf(\"\\n## Upstream license\\n\", end);\n for (let index = 0; index < sections.length; index++) {\n const section = sections[index];\n const page = section[2];\n if (!PLOT_DOC_PAGES.includes(page) || files.has(page) || section[3] !== `${source}/${page}`)\n throw new Error(`Invalid Plot page: ${page}`);\n const body = reference\n .slice(section.index, sections[index + 1]?.index ?? (licenseStart >= 0 ? licenseStart : end))\n .trimEnd()\n .replace(/\\n\\n---$/, \"\");\n files.set(page, body);\n proseLines(body, (line) => {\n for (const match of line.matchAll(/\\bid=[\"']([^\"']+)[\"']/g)) anchors.set(match[1], page);\n return line;\n });\n }\n if (files.size !== PLOT_DOC_PAGES.length) throw new Error(\"Incomplete Plot pages.\");\n\n for (const [page, body] of files) {\n const link = (id: string) => {\n const destination = anchors.get(id);\n return destination && destination !== page\n ? `${posix.relative(posix.dirname(page), destination)}#${id}`\n : `#${id}`;\n };\n files.set(\n page,\n cleanPlotMarkdown(\n proseLines(body, (line) =>\n line\n .split(/(`+[^`]*`+)/g)\n .map((part, index) =>\n index % 2\n ? part\n : part\n .replace(\n /(\\]\\()#([^\\s)]+)([^)]*\\))/g,\n (_match: string, before: string, id: string, after: string) =>\n `${before}${link(id)}${after}`,\n )\n .replace(\n /^( {0,3}\\[[^\\]]+\\]:\\s*)#(\\S+)/,\n (_match: string, before: string, id: string) => `${before}${link(id)}`,\n )\n .replace(\n /(?<!:)\\b(href|src)=([\"'])#([^\"']+)\\2/g,\n (_match: string, attr: string, quote: string, id: string) =>\n `${attr}=${quote}${link(id)}${quote}`,\n ),\n )\n .join(\"\"),\n ),\n ),\n );\n }\n const license =\n licenseStart >= 0\n ? reference.slice(licenseStart + \"\\n## Upstream license\\n\".length, end).trim()\n : undefined;\n if (license) files.set(\"LICENSE\", license + \"\\n\");\n const index =\n `# Observable Plot ${version}\\n\\n> Selected documentation for static charts and maps. Start here, then read the relevant pages.\\n\\n[Versioned upstream documentation](${source})${license ? \" · [License](./LICENSE)\" : \"\"}\\n\\n` +\n [\"features\", \"marks\", \"transforms\"]\n .map(\n (group) =>\n `## ${group[0].toUpperCase() + group.slice(1)}\\n\\n` +\n PLOT_DOC_PAGES.filter((page) => page.startsWith(`${group}/`))\n .map((page) => `- [${page}](./${page})`)\n .join(\"\\n\"),\n )\n .join(\"\\n\\n\") +\n \"\\n\";\n files.set(\"llms.txt\", index);\n return files;\n}\n","import { log } from \"@clack/prompts\";\nimport { existsSync, mkdirSync, mkdtempSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { splitPlotDocs } from \"./splitPlotDocs.ts\";\nimport { combinePlotDocs } from \"./combinePlotDocs.ts\";\nimport { PLOT_DOC_PAGES } from \"./plotDocPages.ts\";\nimport type { PackageDocs } from \"./fetchPackageDocs.ts\";\n\n// Replace local documentation only after every page is ready.\nexport async function fetchPlotDocs(\n version: string,\n options: { preferStored?: boolean } = {},\n): Promise<PackageDocs> {\n const tag = `v${version}`;\n const directory = join(\"docs\", \"observable-plot\");\n try {\n let llm: string | undefined;\n if (options.preferStored !== false) {\n try {\n const response = await fetch(\n \"https://raw.githubusercontent.com/nshiab/setup-data-project/\" +\n `refs/heads/main/docs-cache/observable-plot/${version}/llm.md`,\n );\n if (response.ok) {\n const cached = await response.text();\n if (isStoredReference(cached, version)) llm = cached;\n }\n } catch {\n // A cache is an optimization. An unavailable cache never blocks the tag.\n }\n }\n if (llm === undefined) llm = await generatePlotReference(version);\n const files = splitPlotDocs(llm, version);\n mkdirSync(\"docs\", { recursive: true });\n const staging = mkdtempSync(join(\"docs\", \".plot-\"));\n const contents = join(staging, \"contents\");\n const backup = join(staging, \"previous\");\n try {\n for (const [page, content] of files) {\n const path = join(contents, page);\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, content);\n }\n if (existsSync(directory)) renameSync(directory, backup);\n try {\n renameSync(contents, directory);\n } catch (error) {\n if (existsSync(backup)) renameSync(backup, directory);\n throw error;\n }\n } finally {\n rmSync(staging, { recursive: true, force: true });\n }\n return { llm, index: files.get(\"llms.txt\"), plot: { version, pages: [...PLOT_DOC_PAGES] } };\n } catch (error) {\n log.warn(\n `Could not fetch complete Observable Plot documentation for ${tag}. ` +\n \"Existing files were preserved, but may not match the installed \" +\n \"version. Resolve the refresh failure before using this reference. \" +\n String(error),\n );\n return {};\n }\n}\n\nexport async function generatePlotReference(version: string): Promise<string> {\n if (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(version))\n throw new Error(\"An exact Plot version is required.\");\n const tag = `v${version}`;\n const pages = PLOT_DOC_PAGES;\n const documents = new Map<string, string>();\n const failed: string[] = [];\n // Fetch in small batches to avoid overwhelming GitHub on the first run.\n for (let offset = 0; offset < pages.length; offset += 8) {\n await Promise.all(\n pages.slice(offset, offset + 8).map(async (page) => {\n try {\n const url =\n \"https://raw.githubusercontent.com/observablehq/plot/\" +\n `refs/tags/${tag}/docs/${page}`;\n const response = await fetch(url);\n if (!response.ok) throw new Error(`HTTP ${response.status}`);\n const content = await response.text();\n documents.set(page, content);\n } catch {\n failed.push(page);\n }\n }),\n );\n }\n\n if (failed.length > 0) {\n throw new Error(`Could not fetch ${failed.length} Markdown pages`);\n }\n const response = await fetch(\n `https://raw.githubusercontent.com/observablehq/plot/refs/tags/${tag}/LICENSE`,\n );\n if (!response.ok) throw new Error(`Could not fetch Plot's license: HTTP ${response.status}`);\n const license = await response.text();\n const completion = `<!-- setup-data-project:observable-plot:${version}:complete -->`;\n return combinePlotDocs(version, documents).replace(\n completion,\n `## Upstream license\\n\\n${license.trim()}\\n\\n${completion}`,\n );\n}\n\nfunction isStoredReference(content: string, version: string): boolean {\n const source = `https://github.com/observablehq/plot/tree/v${version}/docs`;\n const metadata = content.split(/\\n\\s*\\n/)[1]?.replace(/\\s+/g, \" \");\n if (\n !content.startsWith(`# Observable Plot ${version}\\n\\n`) ||\n metadata !== `Package: \\`@observablehq/plot@${version}\\`. Source: [v${version}](${source}).` ||\n !content.trimEnd().endsWith(`<!-- setup-data-project:observable-plot:${version}:complete -->`)\n )\n return false;\n\n // Match actual page sections, not TOC entries. Require every selected page\n // exactly once and some upstream heading/content after its source record.\n const sections = [\n ...content.matchAll(/<a id=\"(plot-[^\"]+)\"><\\/a>\\n\\n# ([^\\n]+\\.md)\\n\\nSource:\\s+([^\\s]+)\\n\\n/g),\n ];\n if (sections.length !== PLOT_DOC_PAGES.length) return false;\n const found = new Set<string>();\n for (let index = 0; index < sections.length; index++) {\n const section = sections[index];\n const page = section[2];\n const id = `plot-${page.replace(/\\.md$/, \"\").replaceAll(\"/\", \"--\")}`;\n if (\n !PLOT_DOC_PAGES.includes(page) ||\n found.has(page) ||\n section[1] !== id ||\n section[3] !== `${source}/${page}`\n )\n return false;\n const body = content.slice(section.index + section[0].length, sections[index + 1]?.index);\n if (!/^#{1,6}\\s+\\S/m.test(body)) return false;\n found.add(page);\n }\n return true;\n}\n","import { log } from \"@clack/prompts\";\nimport { fetchPackageDocs, type PackageDocs } from \"./fetchPackageDocs.ts\";\nimport { fetchPlotDocs } from \"./fetchPlotDocs.ts\";\nimport { getInstalledPackageConfigs } from \"./packageRegistry.ts\";\nexport async function syncPackageDocs(\n installedPackages: string[],\n installedVersions: Record<string, string>,\n): Promise<Record<string, PackageDocs>> {\n const mapping: Record<string, PackageDocs> = {};\n for (const pkg of getInstalledPackageConfigs(installedPackages)) {\n const version = installedVersions[pkg.value];\n if (!version) {\n log.warn(\n `Could not determine the installed version of ${pkg.value}. Install the project dependencies, then run the docs script again. Existing documentation may be stale.`,\n );\n continue;\n }\n const docs =\n pkg.value === \"@observablehq/plot\"\n ? await fetchPlotDocs(version)\n : await fetchPackageDocs(pkg.value, version);\n if (docs.index !== undefined || docs.plot) mapping[pkg.value] = docs;\n }\n return mapping;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { isObject } from \"./jsonObject.ts\";\nexport function getInstalledPackageVersions(\n packageSpecifiers: Record<string, string>,\n): Record<string, string> {\n const versions: Record<string, string> = {};\n for (const pkg of Object.keys(packageSpecifiers)) {\n const path = join(\"node_modules\", pkg, \"package.json\");\n if (!existsSync(path)) continue;\n const config: unknown = JSON.parse(readFileSync(path, \"utf8\"));\n if (\n isObject(config) &&\n typeof config.version === \"string\" &&\n /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/.test(config.version)\n )\n versions[pkg] = config.version;\n }\n return versions;\n}\n","import { SUPPORTED_PACKAGES } from \"./packageRegistry.ts\";\n\nexport interface CliOptions {\n help: boolean;\n docs: boolean;\n packages: string[];\n}\n\nconst packageFlags = new Map(\n SUPPORTED_PACKAGES.map((pkg) => [\n `--${pkg.label.replace(/^simple-data-analysis/, \"sda\").replace(/^journalism-/, \"\")}`,\n pkg.value,\n ]),\n);\n\nexport const CLI_HELP = `Usage: setup-data-project [library flags | --docs] [--help]\n\n${Array.from(packageFlags, ([flag, pkg]) => ` ${flag.padEnd(16)} Select ${pkg}.`).join(\"\\n\")}\n --docs Refresh documentation only for installed libraries.\n -h, --help Show this help and exit.\n\nWithout a package flag, choose packages interactively.\nCombine package flags to select libraries without prompting.\nPackage flags install or update selected libraries to latest without prompting,\nand still set up project files and docs.`;\n\nexport function parseArguments(args: string[]): CliOptions {\n const options: CliOptions = { help: false, docs: false, packages: [] };\n\n for (const arg of args) {\n const pkg = packageFlags.get(arg);\n if (arg === \"--help\" || arg === \"-h\") {\n options.help = true;\n } else if (arg === \"--docs\") {\n options.docs = true;\n } else if (pkg) {\n if (!options.packages.includes(pkg)) options.packages.push(pkg);\n } else {\n throw new Error(`Unknown argument: ${arg}. Use --help for usage.`);\n }\n }\n\n if (options.docs && options.packages.length > 0)\n throw new Error(\"--docs cannot be combined with package flags.\");\n return options;\n}\n","#!/usr/bin/env node\nimport { cancel, intro, isCancel, multiselect, outro, select, spinner } from \"@clack/prompts\";\nimport process from \"node:process\";\nimport { execFileSync } from \"node:child_process\";\n\nimport { getRuntime } from \"./helpers/getRuntime.ts\";\nimport { PACKAGE_OPTIONS } from \"./helpers/packageOptions.ts\";\nimport { ensureGitignore } from \"./helpers/ensureGitignore.ts\";\nimport { ensureReadme } from \"./helpers/ensureReadme.ts\";\nimport { ensureTooling } from \"./helpers/ensureTooling.ts\";\nimport { ensureVscode } from \"./helpers/ensureVscode.ts\";\nimport { runPackageManager, installPackages } from \"./helpers/installPackages.ts\";\nimport { getProjectTasks } from \"./helpers/getProjectTasks.ts\";\nimport { createFolderStructure } from \"./helpers/createFolderStructure.ts\";\nimport { ensureEnvFile } from \"./helpers/ensureEnvFile.ts\";\nimport { ensureAgents } from \"./helpers/ensureAgents.ts\";\nimport { getInstalledPackageConfigs } from \"./helpers/packageRegistry.ts\";\nimport { ProjectManifest } from \"./helpers/projectManifest.ts\";\nimport { syncPackageDocs } from \"./helpers/syncPackageDocs.ts\";\nimport { getInstalledPackageVersions } from \"./helpers/getInstalledPackageVersions.ts\";\nimport { CLI_HELP, parseArguments } from \"./helpers/parseArguments.ts\";\n\nasync function main() {\n const cliOptions = parseArguments(process.argv.slice(2));\n if (cliOptions.help) {\n console.log(CLI_HELP);\n return;\n }\n\n const runtime = getRuntime();\n const projectManifest = ProjectManifest.open();\n if (cliOptions.docs) {\n await refreshDocs(projectManifest);\n return;\n }\n console.log();\n intro(`Hi! 👋 (Running on ${runtime})`);\n\n const installedPackages = projectManifest.getInstalledPackages();\n const options = PACKAGE_OPTIONS.map((opt) => ({\n ...opt,\n label: installedPackages.includes(opt.value)\n ? `${opt.label} \\x1b[2m(installed)\\x1b[22m`\n : opt.label,\n }));\n\n const selectedPackages =\n cliOptions.packages.length > 0\n ? cliOptions.packages\n : await multiselect({\n message:\n \"Which libraries would you like to install?\\n\\x1b[2m(space to select, arrows to navigate, enter to confirm)\\x1b[22m\\n\",\n options,\n required: false,\n });\n\n if (isCancel(selectedPackages)) {\n cancel(\"Installation cancelled.\");\n process.exit(0);\n }\n\n const alreadyInstalled = selectedPackages.filter((pkg) => installedPackages.includes(pkg));\n\n const packagesToInstall: string[] = [];\n\n for (const pkg of selectedPackages) {\n if (alreadyInstalled.includes(pkg) && cliOptions.packages.length === 0) {\n const action = await select({\n message: `${pkg} is already installed. What would you like to do?`,\n options: [\n { value: \"skip\", label: \"Keep existing version\" },\n { value: \"update\", label: \"Update to latest\" },\n ],\n });\n\n if (isCancel(action)) {\n cancel(\"Installation cancelled.\");\n process.exit(0);\n }\n\n if (action === \"update\") {\n packagesToInstall.push(`${pkg}@latest`);\n }\n } else {\n packagesToInstall.push(`${pkg}@latest`);\n }\n }\n\n projectManifest.updateTasks(getProjectTasks(runtime));\n\n const sInstall = spinner();\n sInstall.start(\"Installing packages...\");\n\n try {\n await installPackages(packagesToInstall);\n projectManifest.reload();\n const declared = projectManifest.getInstalledPackageSpecifiers();\n if (\n projectManifest\n .getInstalledPackages()\n .some((pkg) =>\n [\"@nshiab/simple-data-analysis\", \"@nshiab/journalism-dataviz\"].includes(pkg),\n ) &&\n !declared[\"@observablehq/plot\"]\n ) {\n await installPackages([\"@observablehq/plot\"]);\n projectManifest.reload();\n }\n await ensureTooling(projectManifest);\n // Reinstall declared dependencies when a project was cloned without node_modules.\n projectManifest.reload();\n const versions = getInstalledPackageVersions(projectManifest.getInstalledPackageSpecifiers());\n if (projectManifest.getInstalledPackages().some((pkg) => !versions[pkg]))\n await runPackageManager([\"install\"]);\n } catch (error) {\n sInstall.stop(\"Package installation failed.\");\n throw error;\n }\n sInstall.stop(\"Packages installed.\");\n\n projectManifest.reload();\n const finalInstalledPackages = getInstalledPackageConfigs(\n projectManifest.getInstalledPackages(),\n ).map((pkg) => pkg.value);\n const docsMapping = await refreshDocs(projectManifest);\n\n const sConfig = spinner();\n sConfig.start(\"Preparing project files and configuration...\");\n try {\n projectManifest.updateTasks(getProjectTasks());\n execFileSync(process.execPath, [\"node_modules/oxfmt/bin/oxfmt\", \"--write\", \"package.json\"], {\n stdio: \"pipe\",\n });\n\n createFolderStructure(finalInstalledPackages);\n ensureGitignore();\n ensureEnvFile();\n ensureVscode();\n ensureReadme(runtime, finalInstalledPackages);\n ensureAgents(docsMapping, runtime, finalInstalledPackages);\n } catch (error) {\n sConfig.stop(\"Project configuration failed.\");\n throw error;\n }\n sConfig.stop(\"Project files and configuration ready.\");\n\n outro(\n process.exitCode\n ? \"Project setup complete; documentation needs attention.\"\n : \"You are all set! 🙌\",\n );\n}\n\nasync function refreshDocs(manifest: ProjectManifest) {\n const packages = getInstalledPackageConfigs(manifest.getInstalledPackages()).map(\n (pkg) => pkg.value,\n );\n const sDocs = spinner();\n sDocs.start(\"Downloading documentation...\");\n try {\n const mapping = await syncPackageDocs(\n packages,\n getInstalledPackageVersions(manifest.getInstalledPackageSpecifiers()),\n );\n if (Object.keys(mapping).length !== packages.length) {\n sDocs.stop(\"Documentation incomplete. See the warnings above.\");\n process.exitCode = 1;\n } else {\n sDocs.stop(\n packages.length > 0 ? \"Documentation downloaded.\" : \"No library documentation to download.\",\n );\n }\n return mapping;\n } catch (error) {\n sDocs.stop(\"Documentation download failed.\");\n throw error;\n }\n}\n\nmain().catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`❌ Error: ${message}`);\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;AAEA,SAAgB,WAAW,WAA4CA,UAAQ,UAAmB;CAChG,OAAO,SAAS,MAAM,QAAQ;AAChC;;;ACGA,MAAa,qBAAsC;CACjD;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,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;EACd,aAAa;EACb,aAAa,SAAS,sBAAsB;EAC5C,aAAa,aAAa,SAAS,sBAAsB;CAC3D,SAAS,OAAO;EACd,QAAQ,KAAK,+BAA+B;EAC5C,MAAM;CACR;CACA,QAAQ,KAAK,wCAAwC;CAErD,MACEA,UAAQ,WACJ,2DACA,qBACN;AACF;AAEA,eAAe,YAAY,UAA2B;CACpD,MAAM,WAAW,2BAA2B,SAAS,qBAAqB,CAAC,CAAC,CAAC,KAC1E,QAAQ,IAAI,KACf;CACA,MAAM,QAAQ,QAAQ;CACtB,MAAM,MAAM,8BAA8B;CAC1C,IAAI;EACF,MAAM,UAAU,MAAM,gBACpB,UACA,4BAA4B,SAAS,8BAA8B,CAAC,CACtE;EACA,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,WAAW,SAAS,QAAQ;GACnD,MAAM,KAAK,mDAAmD;GAC9D,UAAQ,WAAW;EACrB,OACE,MAAM,KACJ,SAAS,SAAS,IAAI,8BAA8B,uCACtD;EAEF,OAAO;CACT,SAAS,OAAO;EACd,MAAM,KAAK,gCAAgC;EAC3C,MAAM;CACR;AACF;AAEA,KAAK,CAAC,CAAC,OAAO,UAAU;CACtB,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACrE,QAAQ,MAAM,YAAY,SAAS;CACnC,UAAQ,WAAW;AACrB,CAAC"}
1
+ {"version":3,"file":"main.mjs","names":["process","metadata.name","metadata.version","process"],"sources":["../src/helpers/getRuntime.ts","../src/helpers/packageRegistry.ts","../src/helpers/packageOptions.ts","../src/helpers/gitignoreEntries.ts","../src/helpers/ensureGitignore.ts","../src/helpers/ensureManagedSection.ts","../src/helpers/ensureReadme.ts","../src/helpers/installPackages.ts","../package.json","../src/helpers/ensureTooling.ts","../src/helpers/ensureVscode.ts","../src/helpers/getProjectTasks.ts","../src/helpers/createFolderStructure.ts","../src/helpers/ensureEnvFile.ts","../src/helpers/ensureAgents.ts","../src/helpers/projectManifest.ts","../src/helpers/fetchPackageDocs.ts","../src/helpers/cleanPlotMarkdown.ts","../src/helpers/getPlotTag.ts","../src/helpers/combinePlotDocs.ts","../src/helpers/plotDocPages.ts","../src/helpers/splitPlotDocs.ts","../src/helpers/fetchPlotDocs.ts","../src/helpers/syncPackageDocs.ts","../src/helpers/getInstalledPackageVersions.ts","../src/helpers/parseArguments.ts","../src/main.ts"],"sourcesContent":["import process from \"node:process\";\nexport type Runtime = \"node\" | \"bun\";\nexport function getRuntime(versions: { bun?: string; node?: string } = process.versions): Runtime {\n return versions.bun ? \"bun\" : \"node\";\n}\n","export interface PackageConfig {\n value: string;\n label: string;\n type: \"sda\" | \"journalism\" | \"other\";\n hint?: string;\n}\n\nexport const SUPPORTED_PACKAGES: PackageConfig[] = [\n {\n value: \"@nshiab/simple-data-analysis\",\n label: \"simple-data-analysis\",\n type: \"sda\",\n hint: \"All the core functionality, plus methods for dataviz, AI, Google sheets, etc.\",\n },\n {\n value: \"@nshiab/simple-data-analysis-core\",\n label: \"simple-data-analysis-core\",\n type: \"sda\",\n hint: \"No fluff. Great for constrained environments, like a cheap server.\",\n },\n {\n value: \"@nshiab/journalism-ai\",\n label: \"journalism-ai\",\n type: \"journalism\",\n hint: \"Easily use AI local models with Ollama or remote models with Gemini/Vertex.\",\n },\n {\n value: \"@nshiab/journalism-google\",\n label: \"journalism-google\",\n type: \"journalism\",\n hint: \"Push and retrieve data from Google Sheets, Google Bucket, and more.\",\n },\n {\n value: \"@nshiab/journalism-web-scraping\",\n label: \"journalism-web-scraping\",\n type: \"journalism\",\n hint: \"Retrieve data from Statistics Canada tables, HTML table, download files...\",\n },\n {\n value: \"@nshiab/journalism-finance\",\n label: \"journalism-finance\",\n type: \"journalism\",\n hint: \"Retrieve financial data, calculate Canadian mortgage payments and taxes...\",\n },\n {\n value: \"@nshiab/journalism-format\",\n label: \"journalism-format\",\n type: \"journalism\",\n hint: \"Easily format dates, numbers, currencies...\",\n },\n {\n value: \"@nshiab/journalism-climate\",\n label: \"journalism-climate\",\n type: \"journalism\",\n hint: \"Retrieve data from Environment Canada APIs and more.\",\n },\n {\n value: \"@nshiab/journalism-dataviz\",\n label: \"journalism-dataviz\",\n type: \"journalism\",\n hint: \"Render charts/maps with Observable Plot or directly in the terminal.\",\n },\n {\n value: \"@nshiab/journalism-geo\",\n label: \"journalism-geo\",\n type: \"journalism\",\n hint: \"Calculate distances, transform 2D coordinates to 3D, wrangle GeoTIFF files...\",\n },\n {\n value: \"@nshiab/journalism-statistics\",\n label: \"journalism-statistics\",\n type: \"journalism\",\n hint: \"Functions for statistical tests, clustering, random path generation...\",\n },\n {\n value: \"@nshiab/journalism-web\",\n label: \"journalism-web\",\n type: \"journalism\",\n hint: \"Web related functions, including downloading data as CSV, extracting ZIP files to URLs...\",\n },\n {\n value: \"@nshiab/journalism-extras\",\n label: \"journalism-extras\",\n type: \"journalism\",\n hint: \"Functions to zip/unzip, sleep, reencode files, create nested directories...\",\n },\n];\n\n// Plot is installed alongside charting libraries, but is not a setup menu option.\nexport const DOCUMENTED_PACKAGES: PackageConfig[] = [\n ...SUPPORTED_PACKAGES,\n { value: \"@nshiab/journalism\", label: \"journalism\", type: \"journalism\" },\n { value: \"@observablehq/plot\", label: \"Observable Plot\", type: \"other\" },\n];\n\nexport function getInstalledPackageConfigs(installedPackages: string[]): PackageConfig[] {\n const installedSet = new Set(installedPackages);\n return DOCUMENTED_PACKAGES.filter((pkg) => installedSet.has(pkg.value));\n}\n","import { SUPPORTED_PACKAGES } from \"./packageRegistry.ts\";\n\nexport const PACKAGE_OPTIONS = SUPPORTED_PACKAGES.map((pkg) => ({\n value: pkg.value,\n label: pkg.label,\n hint: pkg.hint,\n}));\n","export const GITIGNORE_ENTRIES = [\n \"node_modules\",\n \"docs/\",\n \".tmp\",\n \".sda-cache\",\n \".journalism-cache\",\n \"sda/data\",\n \"sda/output\",\n \".env\",\n \".DS_Store\",\n];\n","import { lstatSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { GITIGNORE_ENTRIES } from \"./gitignoreEntries.ts\";\n\nexport const GITIGNORE_SENTINEL = \"# Added by setup-data-project. Do not remove this line.\";\n\nexport function ensureGitignore() {\n const path = \".gitignore\";\n const stats = lstatSync(path, { throwIfNoEntry: false });\n\n if (stats?.isSymbolicLink()) {\n return;\n }\n\n const content = stats === undefined ? \"\" : readFileSync(path, \"utf-8\");\n const hasSentinel = content.split(\"\\n\").some((line) => line.trim() === GITIGNORE_SENTINEL);\n\n if (hasSentinel) {\n const entries = new Set(content.split(\"\\n\").map((line) => line.trim()));\n const missing = GITIGNORE_ENTRIES.filter((entry) => !entries.has(entry));\n if (missing.length)\n writeFileSync(\n path,\n content + (content.endsWith(\"\\n\") ? \"\" : \"\\n\") + missing.join(\"\\n\") + \"\\n\",\n );\n return;\n }\n\n const separator = content === \"\" ? \"\" : content.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n const block = `${GITIGNORE_SENTINEL}\\n${GITIGNORE_ENTRIES.join(\"\\n\")}\\n`;\n writeFileSync(path, content + separator + block);\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\n\ninterface ManagedSectionOptions {\n path: string;\n name: string;\n content: string;\n createContent: (section: string) => string;\n}\n\nexport function ensureManagedSection(\n options: ManagedSectionOptions,\n): \"created\" | \"updated\" | \"unchanged\" | \"missing-markers\" {\n const startMarker = `<!-- setup-data-project:${options.name}:start / Safe to remove if you don't want this generated section. -->`;\n const endMarker = `<!-- setup-data-project:${options.name}:end / End of generated section. -->`;\n const trimmedContent = options.content.trim();\n const section =\n trimmedContent === \"\"\n ? `${startMarker}\\n${endMarker}`\n : `${startMarker}\\n\\n${trimmedContent}\\n\\n${endMarker}`;\n\n if (!existsSync(options.path)) {\n writeFileSync(options.path, ensureFinalNewline(options.createContent(section)));\n return \"created\";\n }\n\n const currentContent = readFileSync(options.path, \"utf-8\");\n const start = new RegExp(\n `<!-- setup-data-project:${options.name}:start(?: / [^\\\\r\\\\n]*?)? -->`,\n ).exec(currentContent);\n const end = new RegExp(`<!-- setup-data-project:${options.name}:end(?: / [^\\\\r\\\\n]*?)? -->`).exec(\n currentContent,\n );\n\n if (!start || !end || end.index < start.index + start[0].length) {\n return \"missing-markers\";\n }\n\n const nextContent =\n currentContent.slice(0, start.index) +\n section +\n currentContent.slice(end.index + end[0].length);\n\n if (nextContent === currentContent) {\n return \"unchanged\";\n }\n\n writeFileSync(options.path, ensureFinalNewline(nextContent));\n return \"updated\";\n}\n\nfunction ensureFinalNewline(content: string): string {\n return content.endsWith(\"\\n\") ? content : content + \"\\n\";\n}\n","import { ensureManagedSection } from \"./ensureManagedSection.ts\";\nimport { getInstalledPackageConfigs } from \"./packageRegistry.ts\";\nimport type { Runtime } from \"./getRuntime.ts\";\nexport function ensureReadme(runtime: Runtime, installedPackages: string[] = []) {\n const run = runtime === \"bun\" ? \"bun run\" : \"npm run\";\n const libraries = getInstalledPackageConfigs(installedPackages)\n .map((pkg) => `\\`${pkg.value}\\``)\n .join(\", \");\n ensureManagedSection({\n path: \"README.md\",\n name: \"libraries\",\n createContent: (section) =>\n `# Data project\\n\\nCreated with [setup-data-project](https://github.com/nshiab/setup-data-project).\\n\\n${section}`,\n content: `${libraries ? `Installed libraries: ${libraries}.\\n\\n` : \"\"}Use sda/main.ts to process source data from sda/data/ and write results to sda/output/. Both data folders are ignored by Git. Put reusable helpers in sda/helpers/ and tests in sda/test/. Name test files \\`*.test.ts\\`.${runtime === \"bun\" ? \" Use Bun 1.3.1 or newer to run checks before adding your first test.\" : \"\"}\n\n- \\`${run} sda\\`: run \\`${run} fix\\`, then run the analysis once if checks pass.\n- \\`${run} sda:watch\\`: do the same on changes to sda/ and .env, excluding sda/output/.\n- \\`${run} sda:status\\`: check whether an SDA run or watcher is active.\n- \\`${run} sda:tests\\`: check formatting, lint, and TypeScript types, then run the tests in sda/test/.\n- \\`${run} sda:tests:watch\\`: rerun those checks and tests on changes to sda/, .env, and tsconfig.json, excluding sda/output/.\n- \\`${run} fix\\`: format files, apply automatic lint fixes, and check types.\n- \\`${run} docs\\`: refresh documentation for the installed library versions.\n- \\`${run} clean\\`: delete cached results and temporary files in .sda-cache/, .journalism-cache/, and .tmp/.\n\nSDA blocks simultaneous runs. Recovery after a forced termination is best effort.\nLock records live in .sda-cache/lock/. The clean command preserves that directory and its parent so an active run keeps its lock.\n\nIn VS Code, install the recommended Oxc extension for formatting and linting. Generated .vscode/settings.json enables formatting and lint fixes on save, plus visual line wrapping. Existing VS Code configuration files are preserved.\n\nThe generated docs/ folder is ignored by Git. Refresh it after cloning or updating dependencies. See AGENTS.md for documentation pointers.`,\n });\n}\n","import { execFile } from \"node:child_process\";\nimport { getRuntime } from \"./getRuntime.ts\";\nexport function runPackageManager(args: string[]): Promise<void> {\n const command = getRuntime() === \"bun\" ? \"bun\" : process.platform === \"win32\" ? \"npm.cmd\" : \"npm\";\n return new Promise((resolve, reject) => {\n execFile(\n command,\n args,\n { maxBuffer: 10 * 1024 * 1024, shell: process.platform === \"win32\" },\n (error, stdout, stderr) => {\n if (error)\n reject(\n new Error(`${command} ${args.join(\" \")} failed.\\n${stderr || stdout}`, {\n cause: error,\n }),\n );\n else resolve();\n },\n );\n });\n}\nexport async function installPackages(\n packages: string[],\n options: { development?: boolean } = {},\n): Promise<void> {\n if (packages.length === 0) return;\n const bun = getRuntime() === \"bun\";\n await runPackageManager([\n bun ? \"add\" : \"install\",\n ...(options.development ? (bun ? [\"--dev\"] : [\"--save-dev\"]) : []),\n ...packages,\n ]);\n}\n","","import { existsSync, writeFileSync } from \"node:fs\";\nimport { ProjectManifest } from \"./projectManifest.ts\";\nimport { getRuntime } from \"./getRuntime.ts\";\nimport { installPackages } from \"./installPackages.ts\";\nimport metadata from \"../../package.json\" with { type: \"json\" };\nconst tools = [\"oxfmt\", \"oxlint\", \"oxlint-tsgolint\", \"@types/node\"];\nexport async function ensureTooling(manifest: ProjectManifest): Promise<void> {\n const runtime = getRuntime();\n const runtimeTools = runtime === \"bun\" ? [...tools, \"@types/bun\"] : tools;\n const installed = manifest.getInstalledPackages();\n await installPackages(\n [\n ...runtimeTools.filter((pkg) => !installed.includes(pkg)).map((pkg) => `${pkg}@latest`),\n ...(installed.includes(metadata.name) ? [] : [`${metadata.name}@${metadata.version}`]),\n ],\n { development: true },\n );\n if (\n ![\".oxlintrc.json\", \".oxlintrc.jsonc\", \"oxlint.config.ts\", \"oxlint.config.mts\"].some((file) =>\n existsSync(file),\n )\n ) {\n writeFileSync(\n \".oxlintrc.json\",\n `{\n \"options\": { \"typeAware\": true, \"typeCheck\": true }\n}\n`,\n );\n }\n if (\n [\".oxfmtrc.json\", \".oxfmtrc.jsonc\", \"oxfmt.config.ts\", \"oxfmt.config.mts\"].every(\n (file) => !existsSync(file),\n )\n )\n writeFileSync(\n \".oxfmtrc.json\",\n `{\n \"ignorePatterns\": [\"docs/**\", \"sda/data/**\", \"sda/output/**\"]\n}\n`,\n );\n if (!existsSync(\"tsconfig.json\"))\n writeFileSync(\n \"tsconfig.json\",\n `{\n \"compilerOptions\": {\n \"target\": \"ES2023\",\n \"module\": \"NodeNext\",\n \"strict\": true,\n \"noEmit\": true,\n \"allowImportingTsExtensions\": true,\n \"erasableSyntaxOnly\": ${runtime === \"node\"},\n \"types\": ${runtime === \"bun\" ? '[\"node\", \"bun\"]' : '[\"node\"]'},\n \"skipLibCheck\": true\n },\n \"include\": [\"sda/**/*.ts\"]\n}\n`,\n );\n}\n","import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\n\nexport function ensureVscode(): void {\n mkdirSync(\".vscode\", { recursive: true });\n const formatter = \"oxc.oxc-vscode\";\n const files = {\n \"extensions.json\": `{\n \"recommendations\": [\"oxc.oxc-vscode\"]\n}\n`,\n \"settings.json\": `${JSON.stringify(\n {\n \"editor.defaultFormatter\": formatter,\n \"[javascript]\": { \"editor.defaultFormatter\": formatter },\n \"[javascriptreact]\": { \"editor.defaultFormatter\": formatter },\n \"[typescript]\": { \"editor.defaultFormatter\": formatter },\n \"[typescriptreact]\": { \"editor.defaultFormatter\": formatter },\n \"oxc.disableNestedConfig\": true,\n \"oxc.fmt.disableNestedConfig\": true,\n \"editor.formatOnSave\": true,\n \"editor.formatOnSaveMode\": \"file\",\n \"editor.codeActionsOnSave\": { \"source.fixAll.oxc\": \"explicit\" },\n \"editor.wordWrap\": \"on\",\n },\n null,\n 2,\n )}\\n`,\n };\n for (const [name, config] of Object.entries(files)) {\n const path = `.vscode/${name}`;\n if (!existsSync(path)) writeFileSync(path, config);\n }\n}\n","import { getRuntime, type Runtime } from \"./getRuntime.ts\";\nexport function getProjectTasks(runtime: Runtime = getRuntime()) {\n const fmt = runtime === \"bun\" ? \"bun run --bun oxfmt\" : \"oxfmt\";\n const lint = `${runtime === \"bun\" ? \"bun run --bun oxlint\" : \"oxlint\"} --type-aware --type-check`;\n const runner = runtime === \"bun\" ? \"bun run --bun --no-env-file sda-run\" : \"sda-run\";\n const tests =\n runtime === \"bun\"\n ? \"bun test --pass-with-no-tests ./sda/test/\"\n : 'node --env-file-if-exists=.env --test \"sda/test/**/*.test.ts\"';\n return {\n sda: `${runner} sda/main.ts`,\n \"sda:watch\": `${runner} --watch sda/main.ts sda .env --ignore sda/output`,\n \"sda:status\": `${runner} --status`,\n \"sda:tests\": `${fmt} --check && ${lint} && ${tests}`,\n \"sda:tests:watch\": `${runner} --watch-tests sda .env tsconfig.json --ignore sda/output`,\n clean: `${runner} --clean`,\n fix: `${fmt} --write && ${lint} --fix --format default`,\n docs: `${runtime === \"bun\" ? \"bun run --bun --no-env-file \" : \"\"}setup-data-project --docs`,\n };\n}\n","import { existsSync, lstatSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport function createFolderStructure(selectedPackages: string[]) {\n const sdaFolder = \"sda\";\n const folders = [\"data\", \"helpers\", \"output\", \"test\"];\n\n if (!existsSync(sdaFolder)) {\n mkdirSync(sdaFolder, { recursive: true });\n }\n\n for (const folder of folders) {\n const path = join(sdaFolder, folder);\n if (!existsSync(path)) {\n mkdirSync(path, { recursive: true });\n }\n }\n\n const gitkeep = join(sdaFolder, \"test\", \".gitkeep\");\n if (lstatSync(gitkeep, { throwIfNoEntry: false }) === undefined) writeFileSync(gitkeep, \"\");\n\n const mainTsPath = join(sdaFolder, \"main.ts\");\n\n let mainTsContent = 'console.log(\"Hello simple-data-analysis!\");\\n';\n\n if (\n selectedPackages.includes(\"@nshiab/simple-data-analysis\") ||\n selectedPackages.includes(\"@nshiab/simple-data-analysis-core\")\n ) {\n const pkg = selectedPackages.includes(\"@nshiab/simple-data-analysis\")\n ? \"@nshiab/simple-data-analysis\"\n : \"@nshiab/simple-data-analysis-core\";\n mainTsContent = `import { SimpleDB } from \"${pkg}\";\n\nconst sdb = new SimpleDB();\nconst table = sdb.newTable();\n\nawait table.loadArray([{ message: \"Hello simple-data-analysis!\" }]).log();\n\nawait sdb.close();\n`;\n }\n\n if (lstatSync(mainTsPath, { throwIfNoEntry: false }) === undefined) {\n writeFileSync(mainTsPath, mainTsContent);\n }\n\n return sdaFolder;\n}\n","import { lstatSync, writeFileSync } from \"node:fs\";\n\nexport function ensureEnvFile() {\n if (lstatSync(\".env\", { throwIfNoEntry: false }) === undefined) {\n writeFileSync(\".env\", \"\");\n }\n}\n","import type { PackageDocs } from \"./fetchPackageDocs.ts\";\nimport { ensureManagedSection } from \"./ensureManagedSection.ts\";\nimport { getInstalledPackageConfigs } from \"./packageRegistry.ts\";\nimport type { Runtime } from \"./getRuntime.ts\";\nexport function ensureAgents(\n docsMapping: Record<string, PackageDocs>,\n runtime: Runtime,\n installedPackages: string[] = Object.keys(docsMapping),\n) {\n const run = runtime === \"bun\" ? \"bun run\" : \"npm run\";\n const links = getInstalledPackageConfigs(installedPackages).map((pkg) => {\n if (pkg.value === \"@observablehq/plot\")\n return `- Observable Plot charts and maps: start at \\`docs/observable-plot/llms.txt\\`, then read the relevant pages for use with writeChart and writeMap.`;\n return `- \\`${pkg.value}\\`: start at \\`docs/${pkg.value.slice(\"@nshiab/\".length)}/llms.txt\\`, then read the relevant API pages and examples.`;\n });\n ensureManagedSection({\n path: \"AGENTS.md\",\n name: \"agents\",\n createContent: (section) => section,\n content: `Read README.md for project guidance and package.json for the installed libraries and scripts. Use the installed libraries. Ask the user before adding a dependency.\n\n${links.length ? `Documentation for these installed libraries is available locally:\\n\\n${links.join(\"\\n\")}\\n\\n` : \"\"}Before making changes or running project commands, run \\`${run} sda:status\\` and follow its instructions.\n\nUse sda/main.ts as the entry point and sda/helpers/ for reusable helpers. Keep one function per helper file, with the file named after the function. Put source data in sda/data/ and results in sda/output/.\n\nAdd focused tests for error-prone transformations, reusable logic with meaningful edge cases, and bug fixes. Mirror source paths under sda/test/: for example, sda/helpers/cleanRows.ts maps to sda/test/helpers/cleanRows.test.ts. Prefer the runtime's built-in test runner.\n\nRun \\`${run} sda\\` to fix and check code, then execute the analysis once.\n\nThe clean script removes cached results and temporary files. Run it only when those cached results can be discarded.\n\nBefore handing off code changes, run \\`${run} sda:tests\\` and resolve failures.`,\n });\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { isObject } from \"./jsonObject.ts\";\nexport class ProjectManifest {\n #config: Record<string, unknown>;\n private constructor(config: Record<string, unknown>) {\n this.#config = config;\n }\n static open(): ProjectManifest {\n if (!existsSync(\"package.json\"))\n return new ProjectManifest({ name: \"data-project\", private: true, type: \"module\" });\n const config: unknown = JSON.parse(readFileSync(\"package.json\", \"utf8\"));\n if (!isObject(config)) throw new Error(\"package.json must contain a JSON object.\");\n return new ProjectManifest(config);\n }\n reload(): void {\n this.#config = ProjectManifest.open().#config;\n }\n getInstalledPackages(): string[] {\n return Object.keys(this.getInstalledPackageSpecifiers());\n }\n getInstalledPackageSpecifiers(): Record<string, string> {\n const packages: Record<string, string> = {};\n for (const key of [\"dependencies\", \"devDependencies\"]) {\n const dependencies = this.#config[key];\n if (isObject(dependencies))\n for (const [name, version] of Object.entries(dependencies)) {\n if (typeof version === \"string\") packages[name] = version;\n }\n }\n return packages;\n }\n updateTasks(tasks: Record<string, string>): void {\n if (this.#config.type === \"commonjs\") {\n throw new Error(\n 'Setup requires an ESM project. Set \"type\": \"module\" in package.json, or use --docs to refresh documentation only.',\n );\n }\n if (this.#config.type === undefined) this.#config.type = \"module\";\n const existing = this.#config.scripts;\n this.#config.scripts = { ...tasks, ...(isObject(existing) ? existing : {}) };\n writeFileSync(\"package.json\", JSON.stringify(this.#config, null, 2) + \"\\n\");\n }\n}\n","import { log } from \"@clack/prompts\";\nimport {\n existsSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { join, posix } from \"node:path\";\nimport { x } from \"tar\";\nimport { DOCUMENTED_PACKAGES } from \"./packageRegistry.ts\";\nexport interface PackageDocs {\n readme?: string;\n index?: string;\n llm?: string;\n plot?: { version: string; pages: string[] };\n}\nexport async function fetchPackageDocs(pkg: string, version: string): Promise<PackageDocs> {\n const config = DOCUMENTED_PACKAGES.find(\n (item) => item.value === pkg && item.value.startsWith(\"@nshiab/\"),\n );\n if (!config || !/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/.test(version))\n throw new Error(`Unsupported package or version: ${pkg}@${version}`);\n const repo = pkg.slice(\"@nshiab/\".length);\n mkdirSync(\"docs\", { recursive: true });\n const staging = mkdtempSync(join(\"docs\", \".download-\"));\n const contents = join(staging, \"contents\");\n const target = join(\"docs\", repo);\n const backup = join(staging, \"previous\");\n try {\n const url = `https://github.com/nshiab/${repo}/releases/download/v${version}/documentation.tar.gz`;\n const response = await fetch(url);\n if (!response.ok) throw new Error(`HTTP ${response.status} from ${url}`);\n const archive = join(staging, \"documentation.tar.gz\");\n writeFileSync(archive, Buffer.from(await response.arrayBuffer()));\n mkdirSync(contents);\n let unsafeEntry: string | undefined;\n await x({\n file: archive,\n cwd: contents,\n strict: true,\n preservePaths: false,\n filter(path, entry) {\n const normalized = posix.normalize(path);\n if (\n path.includes(\"\\\\\") ||\n path.startsWith(\"/\") ||\n normalized === \"..\" ||\n normalized.startsWith(\"../\") ||\n !(\"type\" in entry) ||\n ![\"File\", \"Directory\"].includes(entry.type)\n ) {\n unsafeEntry = path;\n return false;\n }\n return true;\n },\n });\n if (unsafeEntry !== undefined) throw new Error(`Unsafe archive entry: ${unsafeEntry}`);\n for (const path of [\"README.md\", \"LICENSE\", \"llms.txt\", \"docs\"]) {\n if (!existsSync(join(contents, path)))\n throw new Error(`Documentation archive is missing ${path}.`);\n }\n const readme = readFileSync(join(contents, \"README.md\"), \"utf8\");\n const index = readFileSync(join(contents, \"llms.txt\"), \"utf8\");\n if (existsSync(target)) renameSync(target, backup);\n try {\n renameSync(contents, target);\n } catch (error) {\n if (existsSync(backup)) renameSync(backup, target);\n throw error;\n }\n return { readme, index };\n } catch (error) {\n log.warn(\n `Could not refresh ${pkg}@${version}: ${String(error)} Existing documentation was preserved and may be stale. Run the docs script again after resolving the error.`,\n );\n return {};\n } finally {\n rmSync(staging, { recursive: true, force: true });\n }\n}\n","// Plot's source is VitePress Markdown. Keep examples as reference material,\n// but remove the website UI and turn its custom containers into ordinary text.\nexport function cleanPlotMarkdown(content: string): string {\n const preserved: string[] = [];\n const keep = (value: string) => {\n preserved.push(value);\n return `\\uE000PLOT${preserved.length - 1}\\uE000`;\n };\n const lines = content.split(\"\\n\");\n const prose: string[] = [];\n for (let index = 0; index < lines.length; index++) {\n if (/^\\s*<!--/.test(lines[index])) {\n const start = index;\n while (!lines[index].includes(\"-->\") && index + 1 < lines.length) index++;\n prose.push(lines.slice(start, index + 1).join(\"\\n\"));\n continue;\n }\n const opening = lines[index].match(/^ {0,3}(`{3,}|~{3,})(.*)$/);\n if (!opening) {\n prose.push(lines[index]);\n continue;\n }\n const start = index;\n while (++index < lines.length) {\n const closing = lines[index].match(/^ {0,3}(`{3,}|~{3,})\\s*$/);\n if (closing?.[1][0] === opening[1][0] && closing[1].length >= opening[1].length) break;\n }\n if (index >= lines.length) throw new Error(\"Unclosed Plot code fence.\");\n const block = lines.slice(start, index + 1);\n if (opening[2].trim() === \"js-vue\") {\n block[0] = `${opening[1]}text`;\n prose.push(\n keep(\n \"Interactive example template (values in `{{…}}` come from the upstream website):\\n\\n\" +\n block.join(\"\\n\"),\n ),\n );\n } else {\n prose.push(keep(block.join(\"\\n\")));\n }\n }\n let result = prose\n .join(\"\\n\")\n .replace(/<script\\b[^>]*>([\\s\\S]*?)<\\/script>/g, (_match: string, code: string) => {\n const fence = \"`\".repeat(\n Math.max(3, ...[...code.matchAll(/`+/g)].map((match) => match[0].length + 1)),\n );\n return keep(\n `**Upstream example setup.** This code may use Vue and sample data from the linked source page.\\n\\n${fence}js\\n${code.trim()}\\n${fence}`,\n );\n })\n .replace(/^[ \\t]*<!--(?!\\s*setup-data-project:)[\\s\\S]*?-->/gm, \"\")\n .replace(\n /<\\/?[A-Za-z](?:\"[^\"]*\"|'[^']*'|[^'\"><])*>|(`+)[^`\\n]*?\\1/g,\n (part: string, fence: string | undefined) => (fence ? keep(part) : part),\n )\n .replace(/<style\\b[^>]*>[\\s\\S]*?<\\/style>/g, \"\")\n .replace(/<p\\b[^>]*>([\\s\\S]*?)<\\/p>/g, (_match: string, body: string) =>\n /<(?:input|select|label)\\b/.test(body) ? \"\" : body,\n )\n .replace(/<PlotRender\\b[\\s\\S]*?\\/>/g, (component) => {\n const options = component.match(/:options=([\"'])([\\s\\S]*?)\\1/)?.[2];\n const method = component.match(/\\bmethod=[\"'](\\w+)[\"']/)?.[1] ?? \"plot\";\n if (!options) throw new Error(\"Unrecognized PlotRender example.\");\n return keep(`\\`\\`\\`js\\nPlot.${method}(${options});\\n\\`\\`\\``);\n })\n .replace(/<VersionBadge\\b[\\s\\S]*?\\/>/g, (badge) => {\n const version = badge.match(/\\bversion=[\"']([^\"']+)[\"']/)?.[1];\n return version ? `(since v${version})` : \"\";\n })\n .replace(/<\\/?span\\b(?:\"[^\"]*\"|'[^']*'|[^'\">])*>/g, \"\")\n .replace(/<svg\\b[\\s\\S]*?<\\/svg>/g, \"arrow\");\n result = result\n .replace(/^[ \\t]*:::plot\\b([^\\n]*)/gm, (_match: string, options: string) => {\n const url = options.match(/https?:\\/\\/\\S+/)?.[0];\n return url ? `[Interactive example](${url})\\n` : \"\";\n })\n .replace(\n /^([ \\t]*):::(tip|info|warning)\\b[ \\t]*/gm,\n (_match: string, indent: string, kind: string) =>\n `${indent}**${kind[0].toUpperCase() + kind.slice(1)}:** `,\n )\n .replace(/^[ \\t]*:::[ \\t]*$/gm, \"\")\n .replace(/[ \\t]+:::[ \\t]*$/gm, \"\")\n .replace(\n /\\{\\{([\\s\\S]*?)\\}\\}/g,\n (_match: string, expression: string) => `\\`${expression.trim().replace(/\\s+/g, \" \")}\\``,\n )\n .replace(/[ \\t]+$/gm, \"\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .trim();\n return (\n result.replace(\n /\\uE000PLOT(\\d+)\\uE000/g,\n (_match: string, index: string) => preserved[Number(index)],\n ) + \"\\n\"\n );\n}\n","// This release was published with an extra dot in its Git tag.\n// Keep source links and downloads aligned with the actual upstream tag.\nexport function getPlotTag(version: string): string {\n return version === \"0.6.18\" ? `v.${version}` : `v${version}`;\n}\n","import { cleanPlotMarkdown } from \"./cleanPlotMarkdown.ts\";\nimport { posix } from \"node:path\";\nimport { getPlotTag } from \"./getPlotTag.ts\";\n\n// The Plot source uses ATX headings, explicit VitePress IDs, and Markdown fences.\n// Keep code verbatim; rewrite only prose links and anchors while joining pages.\nexport function combinePlotDocs(version: string, documents: Map<string, string>): string {\n const pages = [...documents.keys()].sort();\n const tag = getPlotTag(version);\n const source = `https://github.com/observablehq/plot/tree/${tag}/docs`;\n const anchors = new Map<string, Map<string, string>>();\n const sections = new Map<string, { line: number; title: string; id: string }[]>();\n const pageId = (page: string) => `plot-${page.replace(/\\.md$/, \"\").replaceAll(\"/\", \"--\")}`;\n\n for (const page of pages) {\n const ids = new Map<string, string>();\n const headings: { line: number; title: string; id: string }[] = [];\n const counts = new Map<string, number>();\n proseLines(documents.get(page) ?? \"\", (line, number) => {\n for (const match of line.matchAll(/\\bid=[\"']([^\"']+)[\"']/g)) {\n ids.set(match[1], `${pageId(page)}--${match[1]}`);\n }\n const heading = line.match(/^ {0,3}#{1,6}\\s+(.+?)\\s*#*\\s*$/);\n if (!heading) return line;\n const explicit = heading[1].match(/\\{#([^}]+)\\}/)?.[1];\n const title = heading[1].replace(/\\s*\\{#[^}]+\\}/g, \"\");\n const slug =\n explicit ??\n title\n .replace(/<[^>]*>/g, \"\")\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}_\\s-]/gu, \"\")\n .trim()\n .replace(/\\s+/g, \"-\");\n const count = counts.get(slug) ?? 0;\n counts.set(slug, count + 1);\n const localId = `${slug}${count ? `-${count}` : \"\"}`;\n const id = `${pageId(page)}--${localId}`;\n ids.set(localId, id);\n headings.push({ line: number, title, id });\n return line;\n });\n anchors.set(page, ids);\n sections.set(page, headings);\n }\n\n function link(target: string, page: string): string {\n if (/^(?:[a-z][a-z\\d+.-]*:|\\/\\/)/i.test(target)) return target;\n const [pathAndQuery, fragment] = target.split(\"#\", 2);\n const path = pathAndQuery.split(\"?\", 1)[0];\n const resolved =\n path === \"\"\n ? page\n : posix.normalize(\n path.startsWith(\"/\") ? path.slice(1) : posix.join(posix.dirname(page), path),\n );\n const markdown = [resolved, `${resolved}.md`, `${resolved}/index.md`].find((candidate) =>\n documents.has(candidate),\n );\n if (markdown) {\n const id = fragment\n ? anchors.get(markdown)?.get(decodeURIComponent(fragment))\n : pageId(markdown);\n if (id) return `#${id}`;\n // Preserve an upstream target when a fragment is not a known heading/ID.\n return `${source}/${markdown}${fragment ? `#${fragment}` : \"\"}`;\n }\n if (resolved.endsWith(\".md\")) {\n return `${source}/${resolved}${fragment ? `#${fragment}` : \"\"}`;\n }\n const base = \"https://raw.githubusercontent.com/observablehq/plot/\" + `refs/tags/${tag}/docs/`;\n return path.startsWith(\"/\")\n ? new URL(`public${target}`, base).href\n : new URL(target, `${base}${page}`).href;\n }\n\n const contents = pages\n .flatMap((page) => [\n `- [${page}](#${pageId(page)})`,\n ...(sections.get(page) ?? []).map(\n ({ title, id }) => ` - [${title.replace(/[[\\]]/g, \"\")}](#${id})`,\n ),\n ])\n .join(\"\\n\");\n const combined = pages\n .map((page) => {\n const headings = new Map(\n (sections.get(page) ?? []).map((heading) => [heading.line, heading]),\n );\n const body = proseLines(documents.get(page) ?? \"\", (line, number) => {\n const heading = headings.get(number);\n // Inline code also remains verbatim. Plot's prose links have simple destinations.\n line = line\n .split(/(`+[^`]*`+)/g)\n .map((part, index) => {\n if (index % 2) return part;\n return part\n .replace(\n /(\\]\\()([^\\s)]+)([^)]*\\))/g,\n (_match: string, before: string, target: string, after: string) =>\n `${before}${link(target, page)}${after}`,\n )\n .replace(\n /^( {0,3}\\[[^\\]]+\\]:\\s*)(\\S+)/,\n (_match: string, before: string, target: string) =>\n `${before}${link(target, page)}`,\n )\n .replace(\n /(?<!:)\\b(href|src)=([\"'])([^\"']+)\\2/g,\n (_match: string, attr: string, quote: string, target: string) =>\n `${attr}=${quote}${link(target, page)}${quote}`,\n )\n .replace(\n /\\bid=([\"'])([^\"']+)\\1/g,\n (_match: string, quote: string, id: string) =>\n `id=${quote}${anchors.get(page)?.get(id) ?? id}${quote}`,\n );\n })\n .join(\"\");\n return heading\n ? `<a id=\"${heading.id}\"></a>\\n\\n${line.replace(/\\s*\\{#[^}]+\\}/g, \"\")}`\n : line;\n });\n return `<a id=\"${pageId(page)}\"></a>\\n\\n# ${page}\\n\\nSource: ${source}/${page}\\n\\n${body}`;\n })\n .join(\"\\n\\n---\\n\\n\");\n return cleanPlotMarkdown(\n `# Observable Plot ${version}\\n\\nPackage: \\`@observablehq/plot@${version}\\`. Source: [${tag}](${source}).\\n\\nThis reference combines selected upstream documentation for static charts and maps. Introductory and site pages, interaction helpers, and the Auto and Tip marks are omitted. Website controls are omitted; upstream setup and interactive templates are labeled as reference code. Use the table of contents to find API signatures and examples; links to omitted pages lead to the tagged upstream documentation.\\n\\n## Table of contents\\n\\n${contents}\\n\\n---\\n\\n${combined}\\n\\n<!-- setup-data-project:observable-plot:${version}:complete -->\\n`,\n );\n}\n\nexport function proseLines(\n content: string,\n transform: (line: string, number: number) => string,\n): string {\n let fence: { character: string; length: number } | undefined;\n let script = false;\n return content\n .split(\"\\n\")\n .map((line, number) => {\n const marker = line.match(/^ {0,3}(`{3,}|~{3,})/);\n if (fence) {\n if (\n marker?.[1][0] === fence.character &&\n marker[1].length >= fence.length &&\n /^ {0,3}(?:`+|~+)\\s*$/.test(line)\n )\n fence = undefined;\n return line;\n }\n if (marker) {\n fence = { character: marker[1][0], length: marker[1].length };\n return line;\n }\n if (/^\\s*<script\\b/.test(line)) script = true;\n if (script) {\n if (/<\\/script>/.test(line)) script = false;\n return line;\n }\n return transform(line, number);\n })\n .join(\"\\n\");\n}\n","// Static chart creation references. Keep this explicit so new upstream pages do\n// not silently expand the installed agent reference.\nexport const PLOT_DOC_PAGES: string[] = [\n \"features/plots.md\",\n \"features/marks.md\",\n \"features/scales.md\",\n \"features/projections.md\",\n \"features/legends.md\",\n \"features/facets.md\",\n \"features/formats.md\",\n \"features/curves.md\",\n \"transforms/bin.md\",\n \"transforms/group.md\",\n \"transforms/stack.md\",\n \"transforms/normalize.md\",\n \"transforms/centroid.md\",\n \"transforms/sort.md\",\n \"marks/area.md\",\n \"marks/arrow.md\",\n \"marks/axis.md\",\n \"marks/bar.md\",\n \"marks/bollinger.md\",\n \"marks/box.md\",\n \"marks/cell.md\",\n \"marks/contour.md\",\n \"marks/delaunay.md\",\n \"marks/density.md\",\n \"marks/difference.md\",\n \"marks/dot.md\",\n \"marks/frame.md\",\n \"marks/geo.md\",\n \"marks/grid.md\",\n \"marks/hexgrid.md\",\n \"marks/image.md\",\n \"marks/line.md\",\n \"marks/linear-regression.md\",\n \"marks/link.md\",\n \"marks/raster.md\",\n \"marks/rect.md\",\n \"marks/rule.md\",\n \"marks/text.md\",\n \"marks/tick.md\",\n \"marks/tree.md\",\n \"marks/vector.md\",\n \"marks/waffle.md\",\n].sort();\n","import { cleanPlotMarkdown } from \"./cleanPlotMarkdown.ts\";\nimport { posix } from \"node:path\";\nimport { proseLines } from \"./combinePlotDocs.ts\";\nimport { PLOT_DOC_PAGES } from \"./plotDocPages.ts\";\nimport { getPlotTag } from \"./getPlotTag.ts\";\n\n// Split the cached format without changing code examples or heading anchors.\nexport function splitPlotDocs(reference: string, version: string): Map<string, string> {\n const sections = [\n ...reference.matchAll(\n /<a id=\"(plot-[^\"]+)\"><\\/a>\\n\\n# ([^\\n]+\\.md)\\n\\nSource:\\s+([^\\s]+)\\n\\n/g,\n ),\n ];\n const files = new Map<string, string>();\n const anchors = new Map<string, string>();\n const source = `https://github.com/observablehq/plot/tree/${getPlotTag(version)}/docs`;\n const completion = `<!-- setup-data-project:observable-plot:${version}:complete -->`;\n if (!reference.trimEnd().endsWith(completion)) throw new Error(\"Incomplete Plot reference.\");\n const end = reference.lastIndexOf(completion);\n const licenseStart = reference.lastIndexOf(\"\\n## Upstream license\\n\", end);\n for (let index = 0; index < sections.length; index++) {\n const section = sections[index];\n const page = section[2];\n if (!PLOT_DOC_PAGES.includes(page) || files.has(page) || section[3] !== `${source}/${page}`)\n throw new Error(`Invalid Plot page: ${page}`);\n const body = reference\n .slice(section.index, sections[index + 1]?.index ?? (licenseStart >= 0 ? licenseStart : end))\n .trimEnd()\n .replace(/\\n\\n---$/, \"\");\n files.set(page, body);\n proseLines(body, (line) => {\n for (const match of line.matchAll(/\\bid=[\"']([^\"']+)[\"']/g)) anchors.set(match[1], page);\n return line;\n });\n }\n if (files.size !== PLOT_DOC_PAGES.length) throw new Error(\"Incomplete Plot pages.\");\n\n for (const [page, body] of files) {\n const link = (id: string) => {\n const destination = anchors.get(id);\n return destination && destination !== page\n ? `${posix.relative(posix.dirname(page), destination)}#${id}`\n : `#${id}`;\n };\n files.set(\n page,\n cleanPlotMarkdown(\n proseLines(body, (line) =>\n line\n .split(/(`+[^`]*`+)/g)\n .map((part, index) =>\n index % 2\n ? part\n : part\n .replace(\n /(\\]\\()#([^\\s)]+)([^)]*\\))/g,\n (_match: string, before: string, id: string, after: string) =>\n `${before}${link(id)}${after}`,\n )\n .replace(\n /^( {0,3}\\[[^\\]]+\\]:\\s*)#(\\S+)/,\n (_match: string, before: string, id: string) => `${before}${link(id)}`,\n )\n .replace(\n /(?<!:)\\b(href|src)=([\"'])#([^\"']+)\\2/g,\n (_match: string, attr: string, quote: string, id: string) =>\n `${attr}=${quote}${link(id)}${quote}`,\n ),\n )\n .join(\"\"),\n ),\n ),\n );\n }\n const license =\n licenseStart >= 0\n ? reference.slice(licenseStart + \"\\n## Upstream license\\n\".length, end).trim()\n : undefined;\n if (license) files.set(\"LICENSE\", license + \"\\n\");\n const index =\n `# Observable Plot ${version}\\n\\n> Selected documentation for static charts and maps. Start here, then read the relevant pages.\\n\\n[Versioned upstream documentation](${source})${license ? \" · [License](./LICENSE)\" : \"\"}\\n\\n` +\n [\"features\", \"marks\", \"transforms\"]\n .map(\n (group) =>\n `## ${group[0].toUpperCase() + group.slice(1)}\\n\\n` +\n PLOT_DOC_PAGES.filter((page) => page.startsWith(`${group}/`))\n .map((page) => `- [${page}](./${page})`)\n .join(\"\\n\"),\n )\n .join(\"\\n\\n\") +\n \"\\n\";\n files.set(\"llms.txt\", index);\n return files;\n}\n","import { log } from \"@clack/prompts\";\nimport { existsSync, mkdirSync, mkdtempSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { splitPlotDocs } from \"./splitPlotDocs.ts\";\nimport { combinePlotDocs } from \"./combinePlotDocs.ts\";\nimport { PLOT_DOC_PAGES } from \"./plotDocPages.ts\";\nimport { getPlotTag } from \"./getPlotTag.ts\";\nimport type { PackageDocs } from \"./fetchPackageDocs.ts\";\n\n// Replace local documentation only after every page is ready.\nexport async function fetchPlotDocs(\n version: string,\n options: { preferStored?: boolean } = {},\n): Promise<PackageDocs> {\n const tag = getPlotTag(version);\n const directory = join(\"docs\", \"observable-plot\");\n try {\n let llm: string | undefined;\n if (options.preferStored !== false) {\n try {\n const response = await fetch(\n \"https://raw.githubusercontent.com/nshiab/setup-data-project/\" +\n `refs/heads/main/docs-cache/observable-plot/${version}/llm.md`,\n );\n if (response.ok) {\n const cached = await response.text();\n if (isStoredReference(cached, version)) llm = cached;\n }\n } catch {\n // A cache is an optimization. An unavailable cache never blocks the tag.\n }\n }\n if (llm === undefined) llm = await generatePlotReference(version);\n const files = splitPlotDocs(llm, version);\n mkdirSync(\"docs\", { recursive: true });\n const staging = mkdtempSync(join(\"docs\", \".plot-\"));\n const contents = join(staging, \"contents\");\n const backup = join(staging, \"previous\");\n try {\n for (const [page, content] of files) {\n const path = join(contents, page);\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, content);\n }\n if (existsSync(directory)) renameSync(directory, backup);\n try {\n renameSync(contents, directory);\n } catch (error) {\n if (existsSync(backup)) renameSync(backup, directory);\n throw error;\n }\n } finally {\n rmSync(staging, { recursive: true, force: true });\n }\n return { llm, index: files.get(\"llms.txt\"), plot: { version, pages: [...PLOT_DOC_PAGES] } };\n } catch (error) {\n log.warn(\n `Could not fetch complete Observable Plot documentation for ${tag}. ` +\n \"Existing files were preserved, but may not match the installed \" +\n \"version. Resolve the refresh failure before using this reference. \" +\n String(error),\n );\n return {};\n }\n}\n\nexport async function generatePlotReference(version: string): Promise<string> {\n if (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(version))\n throw new Error(\"An exact Plot version is required.\");\n const tag = getPlotTag(version);\n const pages = PLOT_DOC_PAGES;\n const documents = new Map<string, string>();\n const failed: string[] = [];\n // Fetch in small batches to avoid overwhelming GitHub on the first run.\n for (let offset = 0; offset < pages.length; offset += 8) {\n await Promise.all(\n pages.slice(offset, offset + 8).map(async (page) => {\n try {\n const url =\n \"https://raw.githubusercontent.com/observablehq/plot/\" +\n `refs/tags/${tag}/docs/${page}`;\n const response = await fetch(url);\n if (!response.ok) throw new Error(`HTTP ${response.status}`);\n const content = await response.text();\n documents.set(page, content);\n } catch {\n failed.push(page);\n }\n }),\n );\n }\n\n if (failed.length > 0) {\n throw new Error(`Could not fetch ${failed.length} Markdown pages`);\n }\n const response = await fetch(\n `https://raw.githubusercontent.com/observablehq/plot/refs/tags/${tag}/LICENSE`,\n );\n if (!response.ok) throw new Error(`Could not fetch Plot's license: HTTP ${response.status}`);\n const license = await response.text();\n const completion = `<!-- setup-data-project:observable-plot:${version}:complete -->`;\n return combinePlotDocs(version, documents).replace(\n completion,\n `## Upstream license\\n\\n${license.trim()}\\n\\n${completion}`,\n );\n}\n\nfunction isStoredReference(content: string, version: string): boolean {\n const tag = getPlotTag(version);\n const source = `https://github.com/observablehq/plot/tree/${tag}/docs`;\n const metadata = content.split(/\\n\\s*\\n/)[1]?.replace(/\\s+/g, \" \");\n if (\n !content.startsWith(`# Observable Plot ${version}\\n\\n`) ||\n metadata !== `Package: \\`@observablehq/plot@${version}\\`. Source: [${tag}](${source}).` ||\n !content.trimEnd().endsWith(`<!-- setup-data-project:observable-plot:${version}:complete -->`)\n )\n return false;\n\n // Match actual page sections, not TOC entries. Require every selected page\n // exactly once and some upstream heading/content after its source record.\n const sections = [\n ...content.matchAll(/<a id=\"(plot-[^\"]+)\"><\\/a>\\n\\n# ([^\\n]+\\.md)\\n\\nSource:\\s+([^\\s]+)\\n\\n/g),\n ];\n if (sections.length !== PLOT_DOC_PAGES.length) return false;\n const found = new Set<string>();\n for (let index = 0; index < sections.length; index++) {\n const section = sections[index];\n const page = section[2];\n const id = `plot-${page.replace(/\\.md$/, \"\").replaceAll(\"/\", \"--\")}`;\n if (\n !PLOT_DOC_PAGES.includes(page) ||\n found.has(page) ||\n section[1] !== id ||\n section[3] !== `${source}/${page}`\n )\n return false;\n const body = content.slice(section.index + section[0].length, sections[index + 1]?.index);\n if (!/^#{1,6}\\s+\\S/m.test(body)) return false;\n found.add(page);\n }\n return true;\n}\n","import { log } from \"@clack/prompts\";\nimport { fetchPackageDocs, type PackageDocs } from \"./fetchPackageDocs.ts\";\nimport { fetchPlotDocs } from \"./fetchPlotDocs.ts\";\nimport { getInstalledPackageConfigs } from \"./packageRegistry.ts\";\nexport async function syncPackageDocs(\n installedPackages: string[],\n installedVersions: Record<string, string>,\n): Promise<Record<string, PackageDocs>> {\n const mapping: Record<string, PackageDocs> = {};\n for (const pkg of getInstalledPackageConfigs(installedPackages)) {\n const version = installedVersions[pkg.value];\n if (!version) {\n log.warn(\n `Could not determine the installed version of ${pkg.value}. Install the project dependencies, then run the docs script again. Existing documentation may be stale.`,\n );\n continue;\n }\n const docs =\n pkg.value === \"@observablehq/plot\"\n ? await fetchPlotDocs(version)\n : await fetchPackageDocs(pkg.value, version);\n if (docs.index !== undefined || docs.plot) mapping[pkg.value] = docs;\n }\n return mapping;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { isObject } from \"./jsonObject.ts\";\nexport function getInstalledPackageVersions(\n packageSpecifiers: Record<string, string>,\n): Record<string, string> {\n const versions: Record<string, string> = {};\n for (const pkg of Object.keys(packageSpecifiers)) {\n const path = join(\"node_modules\", pkg, \"package.json\");\n if (!existsSync(path)) continue;\n const config: unknown = JSON.parse(readFileSync(path, \"utf8\"));\n if (\n isObject(config) &&\n typeof config.version === \"string\" &&\n /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/.test(config.version)\n )\n versions[pkg] = config.version;\n }\n return versions;\n}\n","import { SUPPORTED_PACKAGES } from \"./packageRegistry.ts\";\n\nexport interface CliOptions {\n help: boolean;\n docs: boolean;\n packages: string[];\n}\n\nconst packageFlags = new Map(\n SUPPORTED_PACKAGES.map((pkg) => [\n `--${pkg.label.replace(/^simple-data-analysis/, \"sda\").replace(/^journalism-/, \"\")}`,\n pkg.value,\n ]),\n);\n\nexport const CLI_HELP = `Usage: setup-data-project [library flags | --docs] [--help]\n\n${Array.from(packageFlags, ([flag, pkg]) => ` ${flag.padEnd(16)} Select ${pkg}.`).join(\"\\n\")}\n --docs Refresh documentation only for installed libraries.\n -h, --help Show this help and exit.\n\nWithout a package flag, choose packages interactively.\nCombine package flags to select libraries without prompting.\nPackage flags install or update selected libraries to latest without prompting,\nand still set up project files and docs.`;\n\nexport function parseArguments(args: string[]): CliOptions {\n const options: CliOptions = { help: false, docs: false, packages: [] };\n\n for (const arg of args) {\n const pkg = packageFlags.get(arg);\n if (arg === \"--help\" || arg === \"-h\") {\n options.help = true;\n } else if (arg === \"--docs\") {\n options.docs = true;\n } else if (pkg) {\n if (!options.packages.includes(pkg)) options.packages.push(pkg);\n } else {\n throw new Error(`Unknown argument: ${arg}. Use --help for usage.`);\n }\n }\n\n if (options.docs && options.packages.length > 0)\n throw new Error(\"--docs cannot be combined with package flags.\");\n return options;\n}\n","#!/usr/bin/env node\nimport { cancel, intro, isCancel, multiselect, outro, select, spinner } from \"@clack/prompts\";\nimport process from \"node:process\";\nimport { execFileSync } from \"node:child_process\";\n\nimport { getRuntime } from \"./helpers/getRuntime.ts\";\nimport { PACKAGE_OPTIONS } from \"./helpers/packageOptions.ts\";\nimport { ensureGitignore } from \"./helpers/ensureGitignore.ts\";\nimport { ensureReadme } from \"./helpers/ensureReadme.ts\";\nimport { ensureTooling } from \"./helpers/ensureTooling.ts\";\nimport { ensureVscode } from \"./helpers/ensureVscode.ts\";\nimport { runPackageManager, installPackages } from \"./helpers/installPackages.ts\";\nimport { getProjectTasks } from \"./helpers/getProjectTasks.ts\";\nimport { createFolderStructure } from \"./helpers/createFolderStructure.ts\";\nimport { ensureEnvFile } from \"./helpers/ensureEnvFile.ts\";\nimport { ensureAgents } from \"./helpers/ensureAgents.ts\";\nimport { getInstalledPackageConfigs } from \"./helpers/packageRegistry.ts\";\nimport { ProjectManifest } from \"./helpers/projectManifest.ts\";\nimport { syncPackageDocs } from \"./helpers/syncPackageDocs.ts\";\nimport { getInstalledPackageVersions } from \"./helpers/getInstalledPackageVersions.ts\";\nimport { CLI_HELP, parseArguments } from \"./helpers/parseArguments.ts\";\n\nasync function main() {\n const cliOptions = parseArguments(process.argv.slice(2));\n if (cliOptions.help) {\n console.log(CLI_HELP);\n return;\n }\n\n const runtime = getRuntime();\n const projectManifest = ProjectManifest.open();\n if (cliOptions.docs) {\n await refreshDocs(projectManifest);\n return;\n }\n console.log();\n intro(`Hi! 👋 (Running on ${runtime})`);\n\n const installedPackages = projectManifest.getInstalledPackages();\n const options = PACKAGE_OPTIONS.map((opt) => ({\n ...opt,\n label: installedPackages.includes(opt.value)\n ? `${opt.label} \\x1b[2m(installed)\\x1b[22m`\n : opt.label,\n }));\n\n const selectedPackages =\n cliOptions.packages.length > 0\n ? cliOptions.packages\n : await multiselect({\n message:\n \"Which libraries would you like to install?\\n\\x1b[2m(space to select, arrows to navigate, enter to confirm)\\x1b[22m\\n\",\n options,\n required: false,\n });\n\n if (isCancel(selectedPackages)) {\n cancel(\"Installation cancelled.\");\n process.exit(0);\n }\n\n const alreadyInstalled = selectedPackages.filter((pkg) => installedPackages.includes(pkg));\n\n const packagesToInstall: string[] = [];\n\n for (const pkg of selectedPackages) {\n if (alreadyInstalled.includes(pkg) && cliOptions.packages.length === 0) {\n const action = await select({\n message: `${pkg} is already installed. What would you like to do?`,\n options: [\n { value: \"skip\", label: \"Keep existing version\" },\n { value: \"update\", label: \"Update to latest\" },\n ],\n });\n\n if (isCancel(action)) {\n cancel(\"Installation cancelled.\");\n process.exit(0);\n }\n\n if (action === \"update\") {\n packagesToInstall.push(`${pkg}@latest`);\n }\n } else {\n packagesToInstall.push(`${pkg}@latest`);\n }\n }\n\n projectManifest.updateTasks(getProjectTasks(runtime));\n\n const sInstall = spinner();\n sInstall.start(\"Installing packages...\");\n\n try {\n await installPackages(packagesToInstall);\n projectManifest.reload();\n const declared = projectManifest.getInstalledPackageSpecifiers();\n if (\n projectManifest\n .getInstalledPackages()\n .some((pkg) =>\n [\"@nshiab/simple-data-analysis\", \"@nshiab/journalism-dataviz\"].includes(pkg),\n ) &&\n !declared[\"@observablehq/plot\"]\n ) {\n await installPackages([\"@observablehq/plot\"]);\n projectManifest.reload();\n }\n await ensureTooling(projectManifest);\n // Reinstall declared dependencies when a project was cloned without node_modules.\n projectManifest.reload();\n const versions = getInstalledPackageVersions(projectManifest.getInstalledPackageSpecifiers());\n if (projectManifest.getInstalledPackages().some((pkg) => !versions[pkg]))\n await runPackageManager([\"install\"]);\n } catch (error) {\n sInstall.stop(\"Package installation failed.\");\n throw error;\n }\n sInstall.stop(\"Packages installed.\");\n\n projectManifest.reload();\n const finalInstalledPackages = getInstalledPackageConfigs(\n projectManifest.getInstalledPackages(),\n ).map((pkg) => pkg.value);\n const docsMapping = await refreshDocs(projectManifest);\n\n const sConfig = spinner();\n sConfig.start(\"Preparing project files and configuration...\");\n try {\n projectManifest.updateTasks(getProjectTasks());\n execFileSync(process.execPath, [\"node_modules/oxfmt/bin/oxfmt\", \"--write\", \"package.json\"], {\n stdio: \"pipe\",\n });\n\n createFolderStructure(finalInstalledPackages);\n ensureGitignore();\n ensureEnvFile();\n ensureVscode();\n ensureReadme(runtime, finalInstalledPackages);\n ensureAgents(docsMapping, runtime, finalInstalledPackages);\n } catch (error) {\n sConfig.stop(\"Project configuration failed.\");\n throw error;\n }\n sConfig.stop(\"Project files and configuration ready.\");\n\n outro(\n process.exitCode\n ? \"Project setup complete; documentation needs attention.\"\n : \"You are all set! 🙌\",\n );\n}\n\nasync function refreshDocs(manifest: ProjectManifest) {\n const packages = getInstalledPackageConfigs(manifest.getInstalledPackages()).map(\n (pkg) => pkg.value,\n );\n const sDocs = spinner();\n sDocs.start(\"Downloading documentation...\");\n try {\n const mapping = await syncPackageDocs(\n packages,\n getInstalledPackageVersions(manifest.getInstalledPackageSpecifiers()),\n );\n if (Object.keys(mapping).length !== packages.length) {\n sDocs.stop(\"Documentation incomplete. See the warnings above.\");\n process.exitCode = 1;\n } else {\n sDocs.stop(\n packages.length > 0 ? \"Documentation downloaded.\" : \"No library documentation to download.\",\n );\n }\n return mapping;\n } catch (error) {\n sDocs.stop(\"Documentation download failed.\");\n throw error;\n }\n}\n\nmain().catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`❌ Error: ${message}`);\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;AAEA,SAAgB,WAAW,WAA4CA,UAAQ,UAAmB;CAChG,OAAO,SAAS,MAAM,QAAQ;AAChC;;;ACGA,MAAa,qBAAsC;CACjD;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;CACR;AACF;AAGA,MAAa,sBAAuC;CAClD,GAAG;CACH;EAAE,OAAO;EAAsB,OAAO;EAAc,MAAM;CAAa;CACvE;EAAE,OAAO;EAAsB,OAAO;EAAmB,MAAM;CAAQ;AACzE;AAEA,SAAgB,2BAA2B,mBAA8C;CACvF,MAAM,eAAe,IAAI,IAAI,iBAAiB;CAC9C,OAAO,oBAAoB,QAA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AS,sBAAsB;CAC3D,SAAS,OAAO;EACd,QAAQ,KAAK,+BAA+B;EAC5C,MAAM;CACR;CACA,QAAQ,KAAK,wCAAwC;CAErD,MACEA,UAAQ,WACJ,2DACA,qBACN;AACF;AAEA,eAAe,YAAY,UAA2B;CACpD,MAAM,WAAW,2BAA2B,SAAS,qBAAqB,CAAC,CAAC,CAAC,KAC1E,QAAQ,IAAI,KACf;CACA,MAAM,QAAQ,QAAQ;CACtB,MAAM,MAAM,8BAA8B;CAC1C,IAAI;EACF,MAAM,UAAU,MAAM,gBACpB,UACA,4BAA4B,SAAS,8BAA8B,CAAC,CACtE;EACA,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,WAAW,SAAS,QAAQ;GACnD,MAAM,KAAK,mDAAmD;GAC9D,UAAQ,WAAW;EACrB,OACE,MAAM,KACJ,SAAS,SAAS,IAAI,8BAA8B,uCACtD;EAEF,OAAO;CACT,SAAS,OAAO;EACd,MAAM,KAAK,gCAAgC;EAC3C,MAAM;CACR;AACF;AAEA,KAAK,CAAC,CAAC,OAAO,UAAU;CACtB,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACrE,QAAQ,MAAM,YAAY,SAAS;CACnC,UAAQ,WAAW;AACrB,CAAC"}
package/dist/sda.mjs CHANGED
@@ -276,6 +276,10 @@ const { positionals: [entry, ...paths], values } = parseArgs({
276
276
  type: "boolean",
277
277
  default: false
278
278
  },
279
+ "watch-tests": {
280
+ type: "boolean",
281
+ default: false
282
+ },
279
283
  ignore: {
280
284
  type: "string",
281
285
  multiple: true,
@@ -284,7 +288,7 @@ const { positionals: [entry, ...paths], values } = parseArgs({
284
288
  }
285
289
  });
286
290
  if (values.clean) {
287
- if (entry || values.status || values.watch || values.ignore.length) {
291
+ if (entry || values.status || values.watch || values["watch-tests"] || values.ignore.length) {
288
292
  console.error("Usage: sda-run --clean (without other options or paths)");
289
293
  process.exit(1);
290
294
  }
@@ -323,20 +327,21 @@ if (values.clean) {
323
327
  }
324
328
  if (values.status) process.exit(printSdaStatus());
325
329
  if (!entry) {
326
- console.error("Usage: sda-run --clean | --status | [--watch] <entry-file> [watch-paths...] [--ignore path]");
330
+ console.error("Usage: sda-run --clean | --status | [--watch] <entry-file> [watch-paths...] [--ignore path] | --watch-tests <watch-paths...> [--ignore path]");
327
331
  process.exit(1);
328
332
  }
329
- const watching = values.watch;
333
+ const watchingTests = values["watch-tests"];
334
+ const watching = values.watch || watchingTests;
330
335
  const selected = [entry, ...paths].map((path) => resolve(path));
331
336
  const ignored = [SDA_LOCK_DIRECTORY, ...values.ignore].map((path) => resolve(path));
332
337
  const within = (path, root) => path === root || path.startsWith(root + sep);
333
338
  const excluded = (path) => ignored.some((root) => within(path, root));
334
339
  const bun = Boolean(process.versions.bun);
335
- const runCommand = (bun ? "bun run " : "npm run ") + (watching ? "sda:watch" : "sda");
340
+ const runCommand = (bun ? "bun run " : "npm run ") + (watchingTests ? "sda:tests:watch" : watching ? "sda:watch" : "sda");
336
341
  const windows = process.platform === "win32";
337
342
  let releaseLock;
338
343
  let fixer;
339
- let analysis;
344
+ let running;
340
345
  let timer;
341
346
  let checking = false;
342
347
  let closing = false;
@@ -373,6 +378,13 @@ function launch(args, command = process.execPath, summarize = false) {
373
378
  })
374
379
  };
375
380
  }
381
+ function launchScript(script, summarize = false) {
382
+ return launch([
383
+ "run",
384
+ "--silent",
385
+ script
386
+ ], bun ? process.execPath : windows ? "npm.cmd" : "npm", summarize);
387
+ }
376
388
  function refreshWatchers() {
377
389
  const directories = /* @__PURE__ */ new Map();
378
390
  const add = (directory, recursive) => {
@@ -442,16 +454,18 @@ async function check() {
442
454
  if (!needsCheck && !changed) return;
443
455
  checking = true;
444
456
  needsCheck = false;
445
- await stop(analysis);
446
- analysis = void 0;
457
+ await stop(running);
458
+ running = void 0;
447
459
  if (closing) return;
448
460
  refreshWatchers();
449
461
  process.stdout.write("\x1B[2J\x1B[3J\x1B[H");
450
- fixer = launch([
451
- "run",
452
- "--silent",
453
- "fix"
454
- ], bun ? process.execPath : windows ? "npm.cmd" : "npm", true);
462
+ if (watchingTests) {
463
+ changes.check();
464
+ running = launchScript("sda:tests");
465
+ checking = false;
466
+ return;
467
+ }
468
+ fixer = launchScript("fix", true);
455
469
  const fixed = await fixer.done;
456
470
  if (closing) return;
457
471
  needsCheck = changes.check();
@@ -461,7 +475,7 @@ async function check() {
461
475
  if (needsCheck) schedule();
462
476
  else if (fixed === 0) {
463
477
  console.log();
464
- analysis = launch(bun ? ["run", entry] : ["--env-file=.env", entry]);
478
+ running = launch(bun ? ["run", entry] : ["--env-file=.env", entry]);
465
479
  } else console.log("Fix failed. Watching for changes...");
466
480
  }
467
481
  function schedule() {
@@ -473,7 +487,7 @@ async function shutdown(code) {
473
487
  closing = true;
474
488
  clearTimeout(timer);
475
489
  for (const { watcher } of watchers.values()) watcher.close();
476
- await Promise.all([stop(fixer), stop(analysis)]);
490
+ await Promise.all([stop(fixer), stop(running)]);
477
491
  releaseLock?.();
478
492
  process.exit(code);
479
493
  }
@@ -490,11 +504,7 @@ function fail(error) {
490
504
  process.on("SIGINT", () => void shutdown(0));
491
505
  process.on("SIGTERM", () => void shutdown(0));
492
506
  async function runOnce() {
493
- fixer = launch([
494
- "run",
495
- "--silent",
496
- "fix"
497
- ], bun ? process.execPath : windows ? "npm.cmd" : "npm", true);
507
+ fixer = launchScript("fix", true);
498
508
  const fixed = await fixer.done;
499
509
  if (closing) return;
500
510
  if (fixed !== 0) {
@@ -505,12 +515,12 @@ async function runOnce() {
505
515
  fixer = void 0;
506
516
  if (closing) return;
507
517
  console.log();
508
- analysis = launch(bun ? ["run", entry] : ["--env-file=.env", entry]);
509
- await shutdown(await analysis.done ?? 1);
518
+ running = launch(bun ? ["run", entry] : ["--env-file=.env", entry]);
519
+ await shutdown(await running.done ?? 1);
510
520
  }
511
521
  try {
512
- releaseLock = await acquireSdaLock(runCommand);
513
- if (closing) releaseLock();
522
+ if (!watchingTests) releaseLock = await acquireSdaLock(runCommand);
523
+ if (closing) releaseLock?.();
514
524
  else if (watching) {
515
525
  refreshWatchers();
516
526
  check().catch(fail);
package/dist/sda.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sda.mjs","names":["errorCode","delay","errorCode","delay"],"sources":["../src/helpers/sdaLock.ts","../src/helpers/sdaStatus.ts","../src/helpers/pipeFixOutput.ts","../src/helpers/fileChanges.ts","../src/sda.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport {\n existsSync,\n mkdirSync,\n readFileSync,\n readdirSync,\n realpathSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { isObject } from \"./jsonObject.ts\";\n\nexport const SDA_LOCK_DIRECTORY = \".sda-cache/lock\";\n\ntype Claim = { id: string; pid: number; ticket: number; command?: string };\n\nfunction errorCode(error: unknown) {\n return error instanceof Error && \"code\" in error ? error.code : undefined;\n}\n\n// Bakery ordering: publish a unique claim before choosing a ticket, then wait for\n// concurrent ticket choices. Never replace/delete a shared lock during recovery.\n// https://www.microsoft.com/en-us/research/publication/new-solution-dijkstras-concurrent-programming-problem/\nexport async function acquireSdaLock(command: string): Promise<() => void> {\n const directory = resolve(SDA_LOCK_DIRECTORY);\n const id = `${process.pid}-${randomUUID()}`;\n const ownDirectory = join(directory, id);\n mkdirSync(directory, { recursive: true });\n mkdirSync(ownDirectory);\n const release = () => {\n rmSync(ownDirectory, { recursive: true, force: true });\n process.removeListener(\"exit\", release);\n };\n process.once(\"exit\", release);\n\n function readClaim(candidate: string): Claim | undefined {\n const match = /^(\\d+)-[\\da-f-]{36}$/.exec(candidate);\n if (!match) return;\n const pid = Number(match[1]);\n if (!Number.isInteger(pid) || pid <= 0 || pid > 2147483647) return;\n const path = join(directory, candidate);\n try {\n process.kill(pid, 0);\n } catch (error) {\n if (errorCode(error) !== \"ESRCH\") throw error;\n // Claim names are never reused, so another starter cannot acquire this path.\n rmSync(path, { recursive: true, force: true });\n return;\n }\n let record: unknown;\n try {\n record = JSON.parse(readFileSync(join(path, \"owner.json\"), \"utf8\"));\n } catch (error) {\n if (errorCode(error) !== \"ENOENT\") throw error;\n // A directory without a published ticket is still choosing, or has exited.\n return existsSync(path) ? { id: candidate, pid, ticket: 0 } : undefined;\n }\n if (\n !isObject(record) ||\n typeof record.ticket !== \"number\" ||\n !Number.isSafeInteger(record.ticket) ||\n record.ticket < 1 ||\n typeof record.command !== \"string\"\n )\n throw new Error(`Cannot read the SDA lock owned by process ${pid}.`);\n return { id: candidate, pid, ticket: record.ticket, command: record.command };\n }\n\n try {\n let ticket = 1;\n for (const candidate of readdirSync(directory)) {\n const claim = readClaim(candidate);\n if (claim) ticket = Math.max(ticket, claim.ticket + 1);\n }\n writeFileSync(\n join(ownDirectory, \"owner.tmp\"),\n JSON.stringify({ ticket, command, projectRoot: realpathSync(process.cwd()) }),\n );\n renameSync(join(ownDirectory, \"owner.tmp\"), join(ownDirectory, \"owner.json\"));\n const deadline = performance.now() + 5000;\n for (const candidate of readdirSync(directory)) {\n if (candidate === id) continue;\n let claim = readClaim(candidate);\n while (claim?.ticket === 0) {\n if (performance.now() >= deadline)\n throw new Error(\n `Another SDA command is still starting (PID ${claim.pid}). Wait for it to finish starting, then try again.`,\n );\n await delay(10);\n claim = readClaim(candidate);\n }\n if (claim && (claim.ticket < ticket || (claim.ticket === ticket && claim.id < id)))\n throw new Error(\n `${claim.command} is already running${claim.command?.endsWith(\"sda:watch\") ? \" and watching this project's files\" : \" an analysis for this project\"} (PID ${claim.pid}). Wait for it to finish or stop it with Ctrl+C in its terminal, then try again.`,\n );\n }\n return release;\n } catch (error) {\n release();\n throw error;\n }\n}\n","import { execFileSync } from \"node:child_process\";\nimport { readFileSync, readdirSync, realpathSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { isObject } from \"./jsonObject.ts\";\nimport { SDA_LOCK_DIRECTORY } from \"./sdaLock.ts\";\n\nfunction errorCode(error: unknown) {\n return error instanceof Error && \"code\" in error ? error.code : undefined;\n}\n\n// Status is read-only: a missing or dead owner is ignored, never removed.\nexport function printSdaStatus(): number {\n const run = `${process.versions.bun ? \"bun\" : \"npm\"} run`;\n const retry = `${run} sda:status`;\n try {\n const claims = new Map<number, string[]>();\n try {\n for (const name of readdirSync(SDA_LOCK_DIRECTORY)) {\n const match = /^(\\d+)-[\\da-f-]{36}$/.exec(name);\n if (match) {\n const pid = Number(match[1]);\n claims.set(pid, [...(claims.get(pid) ?? []), name]);\n }\n }\n } catch (error) {\n if (errorCode(error) !== \"ENOENT\") throw error;\n }\n const messages: string[] = [];\n for (const [pid, owners] of claims) {\n if (!Number.isInteger(pid) || pid <= 0 || pid > 2147483647)\n throw new Error(\"The recorded SDA PID is invalid.\");\n try {\n process.kill(pid, 0);\n } catch (error) {\n if (errorCode(error) === \"ESRCH\") continue;\n throw error;\n }\n let command: string;\n if (process.platform === \"win32\") {\n if (owners.length !== 1) throw new Error(`PID ${pid} has no unambiguous SDA owner record.`);\n const owner: unknown = JSON.parse(\n readFileSync(join(SDA_LOCK_DIRECTORY, owners[0], \"owner.json\"), \"utf8\"),\n );\n // WMI has no readable cwd. This is the claim's recorded project association,\n // not proof of the live process's cwd or protection against PID reuse.\n if (\n !isObject(owner) ||\n typeof owner.projectRoot !== \"string\" ||\n realpathSync(owner.projectRoot) !== realpathSync(process.cwd())\n )\n throw new Error(`PID ${pid} could not be verified as this project's SDA process.`);\n const result: unknown = JSON.parse(\n execFileSync(\n \"powershell.exe\",\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n \"[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false); \" +\n `(Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}' -ErrorAction Stop).CommandLine | ConvertTo-Json -Compress`,\n ],\n {\n encoding: \"utf8\",\n // A cold PowerShell/CIM startup can exceed five seconds on Windows.\n timeout: 10000,\n maxBuffer: 64 * 1024,\n windowsHide: true,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n },\n ),\n );\n if (typeof result !== \"string\" || !result.trim())\n throw new Error(`PID ${pid} has no readable command line.`);\n command = result;\n } else if (process.platform === \"darwin\" || process.platform === \"linux\") {\n command = execFileSync(\"ps\", [\"-p\", String(pid), \"-o\", \"command=\"], {\n encoding: \"utf8\",\n timeout: 5000,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n }).trim();\n const cwd =\n process.platform === \"linux\"\n ? realpathSync(`/proc/${pid}/cwd`)\n : execFileSync(\"lsof\", [\"-a\", \"-p\", String(pid), \"-d\", \"cwd\", \"-Fn\"], {\n encoding: \"utf8\",\n timeout: 5000,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n })\n .split(\"\\n\")\n .find((line) => line.startsWith(\"n\"))\n ?.slice(1);\n if (!cwd || realpathSync(cwd) !== realpathSync(process.cwd()))\n throw new Error(`PID ${pid} could not be verified as this project's SDA process.`);\n } else {\n throw new Error(\"Active SDA processes cannot be verified on this platform.\");\n }\n const executable = process.argv[1];\n if (\n !executable ||\n (!command.includes(executable) &&\n !command.includes(realpathSync(executable)) &&\n !/(?:[\\\\/]@nshiab[\\\\/]setup-data-project[\\\\/]dist[\\\\/]sda\\.mjs|[\\\\/]node_modules[\\\\/]\\.bin[\\\\/]sda-run)(?:[\"\\s]|$)/.test(\n command,\n ))\n )\n throw new Error(`PID ${pid} could not be verified as this project's SDA process.`);\n messages.push(\n /(?:^|[\"\\s])--watch(?:[\"\\s]|$)/.test(command)\n ? `SDA watcher is running (${run} sda:watch, PID ${pid}). It automatically fixes files and reruns the analysis. If you are an agent, ask the user to stop it with Ctrl+C, then recheck with ${retry} before doing any work.`\n : `SDA analysis is running (${run} sda, PID ${pid}). Wait for it to finish. Recheck with ${retry} in 30 seconds before doing any work.`,\n );\n }\n for (const message of messages) console.log(message);\n if (messages.length) return 1;\n console.log(\"No active SDA process found. You can proceed.\");\n return 0;\n } catch (error) {\n console.error(\n `Unable to verify SDA status: ${error instanceof Error ? error.message : String(error)} If you are an agent, ask the user to confirm that neither ${run} sda nor ${run} sda:watch is running and that you may proceed, then wait for their confirmation before doing any work.`,\n );\n return 2;\n }\n}\n","import { createInterface } from \"node:readline\";\nimport type { Readable } from \"node:stream\";\nimport { stripVTControlCharacters, styleText } from \"node:util\";\n\nexport function pipeFixOutput(output: Readable) {\n const lines = createInterface({ input: output, crlfDelay: Infinity });\n lines.on(\"line\", (line: string) => {\n const plain = stripVTControlCharacters(line);\n if (plain === \"Found 0 warnings and 0 errors.\") return;\n const timing = plain.match(\n /^Finished in ([\\d.]+)(ms|s) on \\d+ files?( with \\d+ rules)? using \\d+ threads?\\.$/,\n );\n if (timing) {\n const label = timing[3] ? \"Linting and type checking\" : \"Formatting\";\n console.log(styleText(\"blue\", `${label}: ${timing[1]} ${timing[2]}`));\n } else {\n // Forward diagnostics and unfamiliar output unchanged, including custom fix scripts.\n console.log(line);\n }\n });\n}\n","import { lstatSync, readdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\ntype Entry = { value: string | null; generation: number };\n// Reconcile the selected tree into one metadata index. Always start at the\n// selected roots: event paths can be incomplete or stale after a directory move.\nexport function createFileChanges(selected: string[], excluded: (path: string) => boolean) {\n const files = new Map<string, Entry>();\n let generation = 0;\n\n function check() {\n generation++;\n let changed = false;\n\n function update(path: string, value: string | null) {\n const previous = files.get(path);\n if (previous) {\n if (previous.value !== value) {\n previous.value = value;\n changed = true;\n }\n previous.generation = generation;\n } else {\n files.set(path, { value, generation });\n changed = true;\n }\n }\n\n function collect(path: string) {\n if (excluded(path) || files.get(path)?.generation === generation) return;\n try {\n const stat = lstatSync(path, { bigint: true });\n if (stat.isDirectory()) {\n const names = readdirSync(path);\n update(path, \"directory\");\n for (const name of names) collect(join(path, name));\n } else {\n update(path, [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(\":\"));\n }\n } catch (error) {\n if (\n !(error instanceof Error) ||\n !(\"code\" in error) ||\n (error.code !== \"ENOENT\" && error.code !== \"ENOTDIR\")\n )\n throw error;\n update(path, null);\n }\n }\n\n for (const path of selected) collect(path);\n // Remove entries not visited in this check without allocating a second map.\n for (const [path, entry] of files) {\n if (entry.generation !== generation) {\n files.delete(path);\n changed = true;\n }\n }\n return changed;\n }\n\n return { check };\n}\n","#!/usr/bin/env node\nimport { existsSync, lstatSync, type FSWatcher, readdirSync, rmSync, watch } from \"node:fs\";\nimport { spawn, spawnSync, type ChildProcess } from \"node:child_process\";\nimport { dirname, join, resolve, sep } from \"node:path\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { parseArgs } from \"node:util\";\nimport { acquireSdaLock, SDA_LOCK_DIRECTORY } from \"./helpers/sdaLock.ts\";\nimport { printSdaStatus } from \"./helpers/sdaStatus.ts\";\nimport { pipeFixOutput } from \"./helpers/pipeFixOutput.ts\";\nimport { createFileChanges } from \"./helpers/fileChanges.ts\";\n\nconst {\n positionals: [entry, ...paths],\n values,\n} = parseArgs({\n allowPositionals: true,\n options: {\n clean: { type: \"boolean\", default: false },\n status: { type: \"boolean\", default: false },\n watch: { type: \"boolean\", default: false },\n ignore: { type: \"string\", multiple: true, default: [] },\n },\n});\nif (values.clean) {\n if (entry || values.status || values.watch || values.ignore.length) {\n console.error(\"Usage: sda-run --clean (without other options or paths)\");\n process.exit(1);\n }\n try {\n for (const path of [\".sda-cache\", \".journalism-cache\", \".tmp\"]) {\n if (path === \".sda-cache\") {\n const stat = lstatSync(path, { throwIfNoEntry: false });\n if (!stat) continue;\n if (!stat.isDirectory()) {\n rmSync(path, { force: true });\n continue;\n }\n // Keep the lock and its parent stable, including during concurrent starts.\n for (const name of readdirSync(path)) {\n const child = join(path, name);\n if (resolve(child) !== resolve(SDA_LOCK_DIRECTORY))\n rmSync(child, { recursive: true, force: true });\n }\n continue;\n }\n rmSync(path, { recursive: true, force: true });\n }\n } catch (error) {\n console.error(\"Could not clean caches: \" + errorMessage(error));\n process.exit(1);\n }\n process.exit(0);\n}\nif (values.status) process.exit(printSdaStatus());\nif (!entry) {\n console.error(\n \"Usage: sda-run --clean | --status | [--watch] <entry-file> [watch-paths...] [--ignore path]\",\n );\n process.exit(1);\n}\nconst watching = values.watch;\nconst selected = [entry, ...paths].map((path) => resolve(path));\nconst ignored = [SDA_LOCK_DIRECTORY, ...values.ignore].map((path) => resolve(path));\nconst within = (path: string, root: string) => path === root || path.startsWith(root + sep);\nconst excluded = (path: string) => ignored.some((root) => within(path, root));\nconst bun = Boolean(process.versions.bun);\nconst runCommand = (bun ? \"bun run \" : \"npm run \") + (watching ? \"sda:watch\" : \"sda\");\nconst windows = process.platform === \"win32\";\ntype Job = { child: ChildProcess; done: Promise<number | null> };\nlet releaseLock: (() => void) | undefined;\nlet fixer: Job | undefined;\nlet analysis: Job | undefined;\nlet timer: ReturnType<typeof setTimeout> | undefined;\nlet checking = false;\nlet closing = false;\nlet needsCheck = true;\nconst changes = createFileChanges(selected, excluded);\nconst watchers = new Map<string, { watcher: FSWatcher; recursive: boolean }>();\n\nfunction launch(args: string[], command = process.execPath, summarize = false) {\n const child = spawn(command, args, {\n // Bun's Windows --bun shim is named node.exe; keep Bun CLI argument parsing.\n argv0: windows && bun && command === process.execPath ? \"bun\" : undefined,\n stdio: [\"inherit\", summarize ? \"pipe\" : \"inherit\", \"inherit\"],\n detached: !windows,\n shell: windows && command === \"npm.cmd\",\n });\n if (summarize && child.stdout) {\n const output = child.stdout;\n pipeFixOutput(output);\n child.once(\"exit\", () => {\n // Background descendants can inherit stdout; don't wait forever for their pipe to close.\n const timeout = setTimeout(() => output.destroy(), 1000);\n child.once(\"close\", () => clearTimeout(timeout));\n });\n }\n const done = new Promise<number | null>((resolve) => {\n child.once(\"error\", (error) => {\n console.error(errorMessage(error));\n resolve(1);\n });\n child.once(\"close\", resolve);\n });\n return { child, done };\n}\n\nfunction refreshWatchers() {\n const directories = new Map<string, boolean>();\n const add = (directory: string, recursive: boolean) => {\n directories.set(directory, recursive || directories.get(directory) || false);\n };\n for (const path of selected) {\n if (excluded(path)) continue;\n if (lstatSync(path, { throwIfNoEntry: false })?.isDirectory()) add(path, true);\n // Watch the parent too, so deleted files and folders can be restored.\n let parent = dirname(path);\n while (!existsSync(parent)) parent = dirname(parent);\n add(parent, parent !== dirname(path));\n }\n for (const [directory, state] of watchers) {\n if (directories.get(directory) !== state.recursive) {\n state.watcher.close();\n watchers.delete(directory);\n }\n }\n for (const [directory, recursive] of directories) {\n if (watchers.has(directory)) continue;\n const watcher = watch(directory, { recursive }, (_event, name) => {\n if (checking || closing) return;\n const changed = name && resolve(directory, name.toString());\n if (\n !changed ||\n (!excluded(changed) &&\n selected.some((path) => within(changed, path) || within(path, changed)))\n )\n schedule();\n });\n watcher.on(\"error\", fail);\n watchers.set(directory, { watcher, recursive });\n }\n}\n\nasync function stop(job: Job | undefined) {\n if (!job?.child.pid) return;\n const pid = job.child.pid;\n if (windows) {\n if (job.child.exitCode === null && job.child.signalCode === null) {\n spawnSync(\"taskkill\", [\"/pid\", String(job.child.pid), \"/T\", \"/F\"], { stdio: \"ignore\" });\n }\n await job.done;\n return;\n }\n const signal = (name: NodeJS.Signals | 0) => {\n try {\n process.kill(-pid, name);\n return true;\n } catch (error) {\n if (errorCode(error) !== \"ESRCH\") throw error;\n return false;\n }\n };\n signal(\"SIGTERM\");\n // The direct child can exit first; retain the grace period for its entire process group.\n const deadline = performance.now() + 1000;\n while (signal(0)) {\n if (performance.now() >= deadline) {\n signal(\"SIGKILL\");\n break;\n }\n await delay(25);\n }\n await job.done;\n}\n\nasync function check() {\n if (closing || checking) return;\n const changed = changes.check();\n if (!needsCheck && !changed) return;\n checking = true;\n needsCheck = false;\n await stop(analysis);\n analysis = undefined;\n if (closing) return;\n refreshWatchers();\n process.stdout.write(\"\\u001b[2J\\u001b[3J\\u001b[H\");\n fixer = launch(\n [\"run\", \"--silent\", \"fix\"],\n bun ? process.execPath : windows ? \"npm.cmd\" : \"npm\",\n true,\n );\n const fixed = await fixer.done;\n if (closing) return;\n // Recheck edits made during fixes; ignore delayed events for unchanged file states.\n needsCheck = changes.check();\n refreshWatchers();\n fixer = undefined;\n checking = false;\n if (needsCheck) {\n schedule();\n } else if (fixed === 0) {\n console.log();\n analysis = launch(bun ? [\"run\", entry] : [\"--env-file=.env\", entry]);\n } else {\n console.log(\"Fix failed. Watching for changes...\");\n }\n}\n\nfunction schedule() {\n clearTimeout(timer);\n timer = setTimeout(() => check().catch(fail), 0);\n}\n\nasync function shutdown(code: number) {\n if (closing) return;\n closing = true;\n clearTimeout(timer);\n for (const { watcher } of watchers.values()) watcher.close();\n await Promise.all([stop(fixer), stop(analysis)]);\n releaseLock?.();\n process.exit(code);\n}\n\nfunction errorCode(error: unknown) {\n return error instanceof Error && \"code\" in error ? error.code : undefined;\n}\n\nfunction errorMessage(error: unknown) {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction fail(error: unknown) {\n console.error(errorMessage(error));\n void shutdown(1);\n}\n\nprocess.on(\"SIGINT\", () => void shutdown(0));\nprocess.on(\"SIGTERM\", () => void shutdown(0));\n\nasync function runOnce() {\n fixer = launch(\n [\"run\", \"--silent\", \"fix\"],\n bun ? process.execPath : windows ? \"npm.cmd\" : \"npm\",\n true,\n );\n const fixed = await fixer.done;\n if (closing) return;\n if (fixed !== 0) {\n await shutdown(fixed ?? 1);\n return;\n }\n await stop(fixer);\n fixer = undefined;\n if (closing) return;\n console.log();\n analysis = launch(bun ? [\"run\", entry] : [\"--env-file=.env\", entry]);\n const result = await analysis.done;\n await shutdown(result ?? 1);\n}\n\ntry {\n releaseLock = await acquireSdaLock(runCommand);\n if (closing) releaseLock();\n else if (watching) {\n refreshWatchers();\n void check().catch(fail);\n } else {\n void runOnce().catch(fail);\n }\n} catch (error) {\n fail(new Error(\"Cannot start \" + runCommand + \": \" + errorMessage(error)));\n}\n"],"mappings":";;;;;;;;;;AAeA,MAAa,qBAAqB;AAIlC,SAASA,YAAU,OAAgB;CACjC,OAAO,iBAAiB,SAAS,UAAU,QA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KAAK,KAAK;CAChB,QAAQ,KAAA;CACR,IAAI,SAAS;CACb,QAAQ,IAAI;CACZ,WAAW,OAAO,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,mBAAmB,KAAK,CAAC;CAEnE,MAAM,SAAS,MADM,SAAS,QACL,CAAC;AAC5B;AAEA,IAAI;CACF,cAAc,MAAM,eAAe,UAAU;CAC7C,IAAI,SAAS,YAAY;MACpB,IAAI,UAAU;EACjB,gBAAgB;EAChB,MAAW,CAAC,CAAC,MAAM,IAAI;CACzB,OACE,QAAa,CAAC,CAAC,MAAM,IAAI;AAE7B,SAAS,OAAO;CACd,qBAAK,IAAI,MAAM,kBAAkB,aAAa,OAAO,aAAa,KAAK,CAAC,CAAC;AAC3E"}
1
+ {"version":3,"file":"sda.mjs","names":["errorCode","delay","errorCode","delay"],"sources":["../src/helpers/sdaLock.ts","../src/helpers/sdaStatus.ts","../src/helpers/pipeFixOutput.ts","../src/helpers/fileChanges.ts","../src/sda.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport {\n existsSync,\n mkdirSync,\n readFileSync,\n readdirSync,\n realpathSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { isObject } from \"./jsonObject.ts\";\n\nexport const SDA_LOCK_DIRECTORY = \".sda-cache/lock\";\n\ntype Claim = { id: string; pid: number; ticket: number; command?: string };\n\nfunction errorCode(error: unknown) {\n return error instanceof Error && \"code\" in error ? error.code : undefined;\n}\n\n// Bakery ordering: publish a unique claim before choosing a ticket, then wait for\n// concurrent ticket choices. Never replace/delete a shared lock during recovery.\n// https://www.microsoft.com/en-us/research/publication/new-solution-dijkstras-concurrent-programming-problem/\nexport async function acquireSdaLock(command: string): Promise<() => void> {\n const directory = resolve(SDA_LOCK_DIRECTORY);\n const id = `${process.pid}-${randomUUID()}`;\n const ownDirectory = join(directory, id);\n mkdirSync(directory, { recursive: true });\n mkdirSync(ownDirectory);\n const release = () => {\n rmSync(ownDirectory, { recursive: true, force: true });\n process.removeListener(\"exit\", release);\n };\n process.once(\"exit\", release);\n\n function readClaim(candidate: string): Claim | undefined {\n const match = /^(\\d+)-[\\da-f-]{36}$/.exec(candidate);\n if (!match) return;\n const pid = Number(match[1]);\n if (!Number.isInteger(pid) || pid <= 0 || pid > 2147483647) return;\n const path = join(directory, candidate);\n try {\n process.kill(pid, 0);\n } catch (error) {\n if (errorCode(error) !== \"ESRCH\") throw error;\n // Claim names are never reused, so another starter cannot acquire this path.\n rmSync(path, { recursive: true, force: true });\n return;\n }\n let record: unknown;\n try {\n record = JSON.parse(readFileSync(join(path, \"owner.json\"), \"utf8\"));\n } catch (error) {\n if (errorCode(error) !== \"ENOENT\") throw error;\n // A directory without a published ticket is still choosing, or has exited.\n return existsSync(path) ? { id: candidate, pid, ticket: 0 } : undefined;\n }\n if (\n !isObject(record) ||\n typeof record.ticket !== \"number\" ||\n !Number.isSafeInteger(record.ticket) ||\n record.ticket < 1 ||\n typeof record.command !== \"string\"\n )\n throw new Error(`Cannot read the SDA lock owned by process ${pid}.`);\n return { id: candidate, pid, ticket: record.ticket, command: record.command };\n }\n\n try {\n let ticket = 1;\n for (const candidate of readdirSync(directory)) {\n const claim = readClaim(candidate);\n if (claim) ticket = Math.max(ticket, claim.ticket + 1);\n }\n writeFileSync(\n join(ownDirectory, \"owner.tmp\"),\n JSON.stringify({ ticket, command, projectRoot: realpathSync(process.cwd()) }),\n );\n renameSync(join(ownDirectory, \"owner.tmp\"), join(ownDirectory, \"owner.json\"));\n const deadline = performance.now() + 5000;\n for (const candidate of readdirSync(directory)) {\n if (candidate === id) continue;\n let claim = readClaim(candidate);\n while (claim?.ticket === 0) {\n if (performance.now() >= deadline)\n throw new Error(\n `Another SDA command is still starting (PID ${claim.pid}). Wait for it to finish starting, then try again.`,\n );\n await delay(10);\n claim = readClaim(candidate);\n }\n if (claim && (claim.ticket < ticket || (claim.ticket === ticket && claim.id < id)))\n throw new Error(\n `${claim.command} is already running${claim.command?.endsWith(\"sda:watch\") ? \" and watching this project's files\" : \" an analysis for this project\"} (PID ${claim.pid}). Wait for it to finish or stop it with Ctrl+C in its terminal, then try again.`,\n );\n }\n return release;\n } catch (error) {\n release();\n throw error;\n }\n}\n","import { execFileSync } from \"node:child_process\";\nimport { readFileSync, readdirSync, realpathSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { isObject } from \"./jsonObject.ts\";\nimport { SDA_LOCK_DIRECTORY } from \"./sdaLock.ts\";\n\nfunction errorCode(error: unknown) {\n return error instanceof Error && \"code\" in error ? error.code : undefined;\n}\n\n// Status is read-only: a missing or dead owner is ignored, never removed.\nexport function printSdaStatus(): number {\n const run = `${process.versions.bun ? \"bun\" : \"npm\"} run`;\n const retry = `${run} sda:status`;\n try {\n const claims = new Map<number, string[]>();\n try {\n for (const name of readdirSync(SDA_LOCK_DIRECTORY)) {\n const match = /^(\\d+)-[\\da-f-]{36}$/.exec(name);\n if (match) {\n const pid = Number(match[1]);\n claims.set(pid, [...(claims.get(pid) ?? []), name]);\n }\n }\n } catch (error) {\n if (errorCode(error) !== \"ENOENT\") throw error;\n }\n const messages: string[] = [];\n for (const [pid, owners] of claims) {\n if (!Number.isInteger(pid) || pid <= 0 || pid > 2147483647)\n throw new Error(\"The recorded SDA PID is invalid.\");\n try {\n process.kill(pid, 0);\n } catch (error) {\n if (errorCode(error) === \"ESRCH\") continue;\n throw error;\n }\n let command: string;\n if (process.platform === \"win32\") {\n if (owners.length !== 1) throw new Error(`PID ${pid} has no unambiguous SDA owner record.`);\n const owner: unknown = JSON.parse(\n readFileSync(join(SDA_LOCK_DIRECTORY, owners[0], \"owner.json\"), \"utf8\"),\n );\n // WMI has no readable cwd. This is the claim's recorded project association,\n // not proof of the live process's cwd or protection against PID reuse.\n if (\n !isObject(owner) ||\n typeof owner.projectRoot !== \"string\" ||\n realpathSync(owner.projectRoot) !== realpathSync(process.cwd())\n )\n throw new Error(`PID ${pid} could not be verified as this project's SDA process.`);\n const result: unknown = JSON.parse(\n execFileSync(\n \"powershell.exe\",\n [\n \"-NoLogo\",\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n \"[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false); \" +\n `(Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}' -ErrorAction Stop).CommandLine | ConvertTo-Json -Compress`,\n ],\n {\n encoding: \"utf8\",\n // A cold PowerShell/CIM startup can exceed five seconds on Windows.\n timeout: 10000,\n maxBuffer: 64 * 1024,\n windowsHide: true,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n },\n ),\n );\n if (typeof result !== \"string\" || !result.trim())\n throw new Error(`PID ${pid} has no readable command line.`);\n command = result;\n } else if (process.platform === \"darwin\" || process.platform === \"linux\") {\n command = execFileSync(\"ps\", [\"-p\", String(pid), \"-o\", \"command=\"], {\n encoding: \"utf8\",\n timeout: 5000,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n }).trim();\n const cwd =\n process.platform === \"linux\"\n ? realpathSync(`/proc/${pid}/cwd`)\n : execFileSync(\"lsof\", [\"-a\", \"-p\", String(pid), \"-d\", \"cwd\", \"-Fn\"], {\n encoding: \"utf8\",\n timeout: 5000,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n })\n .split(\"\\n\")\n .find((line) => line.startsWith(\"n\"))\n ?.slice(1);\n if (!cwd || realpathSync(cwd) !== realpathSync(process.cwd()))\n throw new Error(`PID ${pid} could not be verified as this project's SDA process.`);\n } else {\n throw new Error(\"Active SDA processes cannot be verified on this platform.\");\n }\n const executable = process.argv[1];\n if (\n !executable ||\n (!command.includes(executable) &&\n !command.includes(realpathSync(executable)) &&\n !/(?:[\\\\/]@nshiab[\\\\/]setup-data-project[\\\\/]dist[\\\\/]sda\\.mjs|[\\\\/]node_modules[\\\\/]\\.bin[\\\\/]sda-run)(?:[\"\\s]|$)/.test(\n command,\n ))\n )\n throw new Error(`PID ${pid} could not be verified as this project's SDA process.`);\n messages.push(\n /(?:^|[\"\\s])--watch(?:[\"\\s]|$)/.test(command)\n ? `SDA watcher is running (${run} sda:watch, PID ${pid}). It automatically fixes files and reruns the analysis. If you are an agent, ask the user to stop it with Ctrl+C, then recheck with ${retry} before doing any work.`\n : `SDA analysis is running (${run} sda, PID ${pid}). Wait for it to finish. Recheck with ${retry} in 30 seconds before doing any work.`,\n );\n }\n for (const message of messages) console.log(message);\n if (messages.length) return 1;\n console.log(\"No active SDA process found. You can proceed.\");\n return 0;\n } catch (error) {\n console.error(\n `Unable to verify SDA status: ${error instanceof Error ? error.message : String(error)} If you are an agent, ask the user to confirm that neither ${run} sda nor ${run} sda:watch is running and that you may proceed, then wait for their confirmation before doing any work.`,\n );\n return 2;\n }\n}\n","import { createInterface } from \"node:readline\";\nimport type { Readable } from \"node:stream\";\nimport { stripVTControlCharacters, styleText } from \"node:util\";\n\nexport function pipeFixOutput(output: Readable) {\n const lines = createInterface({ input: output, crlfDelay: Infinity });\n lines.on(\"line\", (line: string) => {\n const plain = stripVTControlCharacters(line);\n if (plain === \"Found 0 warnings and 0 errors.\") return;\n const timing = plain.match(\n /^Finished in ([\\d.]+)(ms|s) on \\d+ files?( with \\d+ rules)? using \\d+ threads?\\.$/,\n );\n if (timing) {\n const label = timing[3] ? \"Linting and type checking\" : \"Formatting\";\n console.log(styleText(\"blue\", `${label}: ${timing[1]} ${timing[2]}`));\n } else {\n // Forward diagnostics and unfamiliar output unchanged, including custom fix scripts.\n console.log(line);\n }\n });\n}\n","import { lstatSync, readdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\ntype Entry = { value: string | null; generation: number };\n// Reconcile the selected tree into one metadata index. Always start at the\n// selected roots: event paths can be incomplete or stale after a directory move.\nexport function createFileChanges(selected: string[], excluded: (path: string) => boolean) {\n const files = new Map<string, Entry>();\n let generation = 0;\n\n function check() {\n generation++;\n let changed = false;\n\n function update(path: string, value: string | null) {\n const previous = files.get(path);\n if (previous) {\n if (previous.value !== value) {\n previous.value = value;\n changed = true;\n }\n previous.generation = generation;\n } else {\n files.set(path, { value, generation });\n changed = true;\n }\n }\n\n function collect(path: string) {\n if (excluded(path) || files.get(path)?.generation === generation) return;\n try {\n const stat = lstatSync(path, { bigint: true });\n if (stat.isDirectory()) {\n const names = readdirSync(path);\n update(path, \"directory\");\n for (const name of names) collect(join(path, name));\n } else {\n update(path, [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(\":\"));\n }\n } catch (error) {\n if (\n !(error instanceof Error) ||\n !(\"code\" in error) ||\n (error.code !== \"ENOENT\" && error.code !== \"ENOTDIR\")\n )\n throw error;\n update(path, null);\n }\n }\n\n for (const path of selected) collect(path);\n // Remove entries not visited in this check without allocating a second map.\n for (const [path, entry] of files) {\n if (entry.generation !== generation) {\n files.delete(path);\n changed = true;\n }\n }\n return changed;\n }\n\n return { check };\n}\n","#!/usr/bin/env node\nimport { existsSync, lstatSync, type FSWatcher, readdirSync, rmSync, watch } from \"node:fs\";\nimport { spawn, spawnSync, type ChildProcess } from \"node:child_process\";\nimport { dirname, join, resolve, sep } from \"node:path\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { parseArgs } from \"node:util\";\nimport { acquireSdaLock, SDA_LOCK_DIRECTORY } from \"./helpers/sdaLock.ts\";\nimport { printSdaStatus } from \"./helpers/sdaStatus.ts\";\nimport { pipeFixOutput } from \"./helpers/pipeFixOutput.ts\";\nimport { createFileChanges } from \"./helpers/fileChanges.ts\";\n\nconst {\n positionals: [entry, ...paths],\n values,\n} = parseArgs({\n allowPositionals: true,\n options: {\n clean: { type: \"boolean\", default: false },\n status: { type: \"boolean\", default: false },\n watch: { type: \"boolean\", default: false },\n \"watch-tests\": { type: \"boolean\", default: false },\n ignore: { type: \"string\", multiple: true, default: [] },\n },\n});\nif (values.clean) {\n if (entry || values.status || values.watch || values[\"watch-tests\"] || values.ignore.length) {\n console.error(\"Usage: sda-run --clean (without other options or paths)\");\n process.exit(1);\n }\n try {\n for (const path of [\".sda-cache\", \".journalism-cache\", \".tmp\"]) {\n if (path === \".sda-cache\") {\n const stat = lstatSync(path, { throwIfNoEntry: false });\n if (!stat) continue;\n if (!stat.isDirectory()) {\n rmSync(path, { force: true });\n continue;\n }\n // Keep the lock and its parent stable, including during concurrent starts.\n for (const name of readdirSync(path)) {\n const child = join(path, name);\n if (resolve(child) !== resolve(SDA_LOCK_DIRECTORY))\n rmSync(child, { recursive: true, force: true });\n }\n continue;\n }\n rmSync(path, { recursive: true, force: true });\n }\n } catch (error) {\n console.error(\"Could not clean caches: \" + errorMessage(error));\n process.exit(1);\n }\n process.exit(0);\n}\nif (values.status) process.exit(printSdaStatus());\nif (!entry) {\n console.error(\n \"Usage: sda-run --clean | --status | [--watch] <entry-file> [watch-paths...] [--ignore path] | --watch-tests <watch-paths...> [--ignore path]\",\n );\n process.exit(1);\n}\nconst watchingTests = values[\"watch-tests\"];\nconst watching = values.watch || watchingTests;\nconst selected = [entry, ...paths].map((path) => resolve(path));\nconst ignored = [SDA_LOCK_DIRECTORY, ...values.ignore].map((path) => resolve(path));\nconst within = (path: string, root: string) => path === root || path.startsWith(root + sep);\nconst excluded = (path: string) => ignored.some((root) => within(path, root));\nconst bun = Boolean(process.versions.bun);\nconst runCommand =\n (bun ? \"bun run \" : \"npm run \") +\n (watchingTests ? \"sda:tests:watch\" : watching ? \"sda:watch\" : \"sda\");\nconst windows = process.platform === \"win32\";\ntype Job = { child: ChildProcess; done: Promise<number | null> };\nlet releaseLock: (() => void) | undefined;\nlet fixer: Job | undefined;\nlet running: Job | undefined;\nlet timer: ReturnType<typeof setTimeout> | undefined;\nlet checking = false;\nlet closing = false;\nlet needsCheck = true;\nconst changes = createFileChanges(selected, excluded);\nconst watchers = new Map<string, { watcher: FSWatcher; recursive: boolean }>();\n\nfunction launch(args: string[], command = process.execPath, summarize = false) {\n const child = spawn(command, args, {\n // Bun's Windows --bun shim is named node.exe; keep Bun CLI argument parsing.\n argv0: windows && bun && command === process.execPath ? \"bun\" : undefined,\n stdio: [\"inherit\", summarize ? \"pipe\" : \"inherit\", \"inherit\"],\n detached: !windows,\n shell: windows && command === \"npm.cmd\",\n });\n if (summarize && child.stdout) {\n const output = child.stdout;\n pipeFixOutput(output);\n child.once(\"exit\", () => {\n // Background descendants can inherit stdout; don't wait forever for their pipe to close.\n const timeout = setTimeout(() => output.destroy(), 1000);\n child.once(\"close\", () => clearTimeout(timeout));\n });\n }\n const done = new Promise<number | null>((resolve) => {\n child.once(\"error\", (error) => {\n console.error(errorMessage(error));\n resolve(1);\n });\n child.once(\"close\", resolve);\n });\n return { child, done };\n}\n\nfunction launchScript(script: string, summarize = false) {\n return launch(\n [\"run\", \"--silent\", script],\n bun ? process.execPath : windows ? \"npm.cmd\" : \"npm\",\n summarize,\n );\n}\n\nfunction refreshWatchers() {\n const directories = new Map<string, boolean>();\n const add = (directory: string, recursive: boolean) => {\n directories.set(directory, recursive || directories.get(directory) || false);\n };\n for (const path of selected) {\n if (excluded(path)) continue;\n if (lstatSync(path, { throwIfNoEntry: false })?.isDirectory()) add(path, true);\n // Watch the parent too, so deleted files and folders can be restored.\n let parent = dirname(path);\n while (!existsSync(parent)) parent = dirname(parent);\n add(parent, parent !== dirname(path));\n }\n for (const [directory, state] of watchers) {\n if (directories.get(directory) !== state.recursive) {\n state.watcher.close();\n watchers.delete(directory);\n }\n }\n for (const [directory, recursive] of directories) {\n if (watchers.has(directory)) continue;\n const watcher = watch(directory, { recursive }, (_event, name) => {\n if (checking || closing) return;\n const changed = name && resolve(directory, name.toString());\n if (\n !changed ||\n (!excluded(changed) &&\n selected.some((path) => within(changed, path) || within(path, changed)))\n )\n schedule();\n });\n watcher.on(\"error\", fail);\n watchers.set(directory, { watcher, recursive });\n }\n}\n\nasync function stop(job: Job | undefined) {\n if (!job?.child.pid) return;\n const pid = job.child.pid;\n if (windows) {\n if (job.child.exitCode === null && job.child.signalCode === null) {\n spawnSync(\"taskkill\", [\"/pid\", String(job.child.pid), \"/T\", \"/F\"], { stdio: \"ignore\" });\n }\n await job.done;\n return;\n }\n const signal = (name: NodeJS.Signals | 0) => {\n try {\n process.kill(-pid, name);\n return true;\n } catch (error) {\n if (errorCode(error) !== \"ESRCH\") throw error;\n return false;\n }\n };\n signal(\"SIGTERM\");\n // The direct child can exit first; retain the grace period for its entire process group.\n const deadline = performance.now() + 1000;\n while (signal(0)) {\n if (performance.now() >= deadline) {\n signal(\"SIGKILL\");\n break;\n }\n await delay(25);\n }\n await job.done;\n}\n\nasync function check() {\n if (closing || checking) return;\n const changed = changes.check();\n if (!needsCheck && !changed) return;\n checking = true;\n needsCheck = false;\n await stop(running);\n running = undefined;\n if (closing) return;\n refreshWatchers();\n process.stdout.write(\"\\u001b[2J\\u001b[3J\\u001b[H\");\n if (watchingTests) {\n // A fresh run sees edits made while the previous process was stopping.\n changes.check();\n running = launchScript(\"sda:tests\");\n checking = false;\n return;\n }\n fixer = launchScript(\"fix\", true);\n const fixed = await fixer.done;\n if (closing) return;\n // Recheck edits made during fixes; ignore delayed events for unchanged file states.\n needsCheck = changes.check();\n refreshWatchers();\n fixer = undefined;\n checking = false;\n if (needsCheck) {\n schedule();\n } else if (fixed === 0) {\n console.log();\n running = launch(bun ? [\"run\", entry] : [\"--env-file=.env\", entry]);\n } else {\n console.log(\"Fix failed. Watching for changes...\");\n }\n}\n\nfunction schedule() {\n clearTimeout(timer);\n timer = setTimeout(() => check().catch(fail), 0);\n}\n\nasync function shutdown(code: number) {\n if (closing) return;\n closing = true;\n clearTimeout(timer);\n for (const { watcher } of watchers.values()) watcher.close();\n await Promise.all([stop(fixer), stop(running)]);\n releaseLock?.();\n process.exit(code);\n}\n\nfunction errorCode(error: unknown) {\n return error instanceof Error && \"code\" in error ? error.code : undefined;\n}\n\nfunction errorMessage(error: unknown) {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction fail(error: unknown) {\n console.error(errorMessage(error));\n void shutdown(1);\n}\n\nprocess.on(\"SIGINT\", () => void shutdown(0));\nprocess.on(\"SIGTERM\", () => void shutdown(0));\n\nasync function runOnce() {\n fixer = launchScript(\"fix\", true);\n const fixed = await fixer.done;\n if (closing) return;\n if (fixed !== 0) {\n await shutdown(fixed ?? 1);\n return;\n }\n await stop(fixer);\n fixer = undefined;\n if (closing) return;\n console.log();\n running = launch(bun ? [\"run\", entry] : [\"--env-file=.env\", entry]);\n const result = await running.done;\n await shutdown(result ?? 1);\n}\n\ntry {\n if (!watchingTests) releaseLock = await acquireSdaLock(runCommand);\n if (closing) releaseLock?.();\n else if (watching) {\n refreshWatchers();\n void check().catch(fail);\n } else {\n void runOnce().catch(fail);\n }\n} catch (error) {\n fail(new Error(\"Cannot start \" + runCommand + \": \" + errorMessage(error)));\n}\n"],"mappings":";;;;;;;;;;AAeA,MAAa,qBAAqB;AAIlC,SAASA,YAAU,OAAgB;CACjC,OAAO,iBAAiB,SAAS,UAAU,QAAQ,MAAM,OAAO,KAAA;AAClE;AAKA,eAAsB,eAAe,SAAsC;CACzE,MAAM,YAAY,QAAQ,kBAAkB;CAC5C,MAAM,KAAK,GAAG,QAAQ,IAAI,GAAG,WAAW;CACxC,MAAM,eAAe,KAAK,WAAW,EAAE;CACvC,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;CACxC,UAAU,YAAY;CACtB,MAAM,gBAAgB;EACpB,OAAO,cAAc;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACrD,QAAQ,eAAe,QAAQ,OAAO;CACxC;CACA,QAAQ,KAAK,QAAQ,OAAO;CAE5B,SAAS,UAAU,WAAsC;EACvD,MAAM,QAAQ,uBAAuB,KAAK,SAAS;EACnD,IAAI,CAAC,OAAO;EACZ,MAAM,MAAM,OAAO,MAAM,EAAE;EAC3B,IAAI,CAAC,OAAO,UAAU,GAAG,KAAK,OAAO,KAAK,MAAM,YAAY;EAC5D,MAAM,OAAO,KAAK,WAAW,SAAS;EACtC,IAAI;GACF,QAAQ,KAAK,KAAK,CAAC;EACrB,SAAS,OAAO;GACd,I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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nshiab/setup-data-project",
3
- "version": "4.0.11",
3
+ "version": "4.0.13",
4
4
  "description": "Quickly kick off a project using simple-data-analysis-core, simple-data-analysis, and journalism libraries.",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/nshiab/setup-data-project",