saturndocs 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/auth-OIEL34E4.js +16 -0
  2. package/dist/{chunk-3V753MRI.js → chunk-32ATWMIS.js} +3 -3
  3. package/dist/{chunk-U7PKMSB3.js → chunk-3EW6ZPL6.js} +5 -5
  4. package/dist/{chunk-GYRVGWDM.js → chunk-3KCCCMQY.js} +408 -36
  5. package/dist/{chunk-SABK3R2P.js → chunk-3X2NBWZN.js} +245 -161
  6. package/dist/chunk-5ZYUBLEH.js +5154 -0
  7. package/dist/{chunk-N7QPZMLP.js → chunk-6EKGBIUR.js} +2 -2
  8. package/dist/{chunk-CMNX5DLQ.js → chunk-BOWRQKXR.js} +12 -6
  9. package/dist/chunk-E3G56DR2.js +949 -0
  10. package/dist/chunk-FUZE54DG.js +905 -0
  11. package/dist/chunk-HBSJ4Z4S.js +53 -0
  12. package/dist/{chunk-5KX4ZK5E.js → chunk-IJOYWJVM.js} +13 -7
  13. package/dist/chunk-IWIVHHZI.js +426 -0
  14. package/dist/{chunk-XO4CUC7V.js → chunk-PU37LVIF.js} +3 -3
  15. package/dist/{chunk-STCCGFKC.js → chunk-RKM7YWPD.js} +25 -6
  16. package/dist/{chunk-KGJESHJC.js → chunk-T3MCJYSF.js} +1 -1
  17. package/dist/chunk-TEYHAN2L.js +90 -0
  18. package/dist/chunk-VDGVERLX.js +87 -0
  19. package/dist/{chunk-S45UWCML.js → chunk-W3FZTCKV.js} +15 -13
  20. package/dist/chunk-WMS6FUKK.js +414 -0
  21. package/dist/chunk-WXLJZ7RD.js +115 -0
  22. package/dist/chunk-YGVC4N4V.js +29 -0
  23. package/dist/chunk-YPWPLIEZ.js +86 -0
  24. package/dist/cli.js +6 -6
  25. package/dist/coverage-SRIA65FT.js +15 -0
  26. package/dist/dist-LJSALT4X.js +150 -0
  27. package/dist/index.d.ts +99 -34
  28. package/dist/index.js +142 -49
  29. package/dist/{init-7T5TEPBH.js → init-Y3GDNDWW.js} +5 -3
  30. package/dist/lint-XM26WIGE.js +13 -0
  31. package/dist/login-HIXLPRUI.js +22 -0
  32. package/dist/{manage-MKH27U3B.js → manage-3HEBB3EQ.js} +6 -2
  33. package/dist/nav-K43WZJ4J.js +14 -0
  34. package/dist/openapiCheck-CL2AH3YC.js +105 -0
  35. package/dist/pages-4VWB7Z4S.js +16 -0
  36. package/dist/{read-DMSJUEDA.js → read-DYGYUOFK.js} +5 -4
  37. package/dist/{read-ZEVUZNNB.js → read-RKT6HUZ7.js} +41 -7
  38. package/dist/requests-CZYE6GI3.js +13 -0
  39. package/dist/{schema-XJUEZSIW.js → schema-QMJMGD5P.js} +3 -3
  40. package/dist/{sites-I4WI2MPG.js → sites-JKS25SEM.js} +5 -4
  41. package/dist/{status-7R3NOI5H.js → status-FM2ALQUJ.js} +4 -4
  42. package/dist/{suggestions-4WFQ3APX.js → suggestions-Z6XIHMFN.js} +13 -7
  43. package/dist/unavailable-DVPNUO3J.js +40 -0
  44. package/dist/validate-X42T4TJ6.js +12 -0
  45. package/package.json +14 -7
  46. package/dist/auth-FRCFGNYT.js +0 -14
  47. package/dist/brokenLinks-TTOBP4P7.js +0 -48
  48. package/dist/build-F5PWGP57.js +0 -39
  49. package/dist/chunk-3P2OFTXR.js +0 -71
  50. package/dist/chunk-I6U4V7B4.js +0 -1552
  51. package/dist/chunk-OEAEX5YW.js +0 -51
  52. package/dist/chunk-OZWTXMO3.js +0 -584
  53. package/dist/chunk-QLFODLVN.js +0 -46
  54. package/dist/chunk-R3X2DPFF.js +0 -568
  55. package/dist/chunk-TKISMN3P.js +0 -39
  56. package/dist/chunk-VNYDYHXM.js +0 -22
  57. package/dist/chunk-VXEUNRVA.js +0 -26
  58. package/dist/deploy-QU7DCKWU.js +0 -11
  59. package/dist/dev-VDSDCBO2.js +0 -43
  60. package/dist/openapiCheck-KGBQJTIQ.js +0 -66
  61. package/dist/pages-HIPXRLSY.js +0 -15
  62. package/dist/requests-H5MIGBIS.js +0 -13
  63. package/dist/validate-VXL4PL42.js +0 -30
@@ -1,9 +1,13 @@
1
1
  import {
2
2
  loadDocsConfig
3
- } from "./chunk-R3X2DPFF.js";
3
+ } from "./chunk-E3G56DR2.js";
4
4
  import {
5
- messageOf
6
- } from "./chunk-VNYDYHXM.js";
5
+ createResultWriter,
6
+ failureResult,
7
+ invalidInput2 as invalidInput,
8
+ resolveGlobalOptions,
9
+ successResult
10
+ } from "./chunk-3KCCCMQY.js";
7
11
 
8
12
  // src/commands/init.ts
9
13
  import { existsSync } from "fs";
@@ -52,54 +56,54 @@ var BrandFetcher = class {
52
56
  throw new Error(`request budget exceeded (${this.maxRequests})`);
53
57
  }
54
58
  this.count += 1;
55
- const response = await this.fetchOnce(url, options.accept);
56
- const location = response.headers.get("location");
57
- if (isRedirect(response.status) && location) {
58
- if (redirects >= this.maxRedirects) {
59
- throw new Error(`redirect limit exceeded (${this.maxRedirects})`);
59
+ const controller = new AbortController();
60
+ const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
61
+ try {
62
+ const fetchImpl = this.fetchImpl;
63
+ const response = await fetchImpl(url, {
64
+ redirect: "manual",
65
+ signal: controller.signal,
66
+ headers: {
67
+ "user-agent": USER_AGENT,
68
+ accept: options.accept ?? "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
69
+ }
70
+ });
71
+ const location = response.headers.get("location");
72
+ if (isRedirect(response.status) && location) {
73
+ void response.body?.cancel().catch(() => void 0);
74
+ if (redirects >= this.maxRedirects) {
75
+ throw new Error(`redirect limit exceeded (${this.maxRedirects})`);
76
+ }
77
+ const next = new URL(location, url);
78
+ if (next.protocol !== "http:" && next.protocol !== "https:") {
79
+ throw new Error(`redirect target is not http/https: ${next.href}`);
80
+ }
81
+ await this.validate(next);
82
+ redirects += 1;
83
+ url = next;
84
+ continue;
60
85
  }
61
- const next = new URL(location, url);
62
- if (next.protocol !== "http:" && next.protocol !== "https:") {
63
- throw new Error(`redirect target is not http/https: ${next.href}`);
86
+ if (!response.ok) {
87
+ void response.body?.cancel().catch(() => void 0);
88
+ throw new Error(`fetch failed for ${url.href}: HTTP ${response.status}`);
64
89
  }
65
- await this.validate(next);
66
- redirects += 1;
67
- url = next;
68
- continue;
69
- }
70
- if (!response.ok) {
71
- throw new Error(`fetch failed for ${url.href}: HTTP ${response.status}`);
90
+ const maxBytes = options.maxBytes ?? DEFAULT_PAGE_MAX_BYTES;
91
+ const body = await readResponseBytes(
92
+ response,
93
+ maxBytes,
94
+ options.truncate === true
95
+ );
96
+ const contentType = response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
97
+ return {
98
+ url: url.toString(),
99
+ status: response.status,
100
+ contentType,
101
+ bytes: body.bytes,
102
+ truncated: body.truncated
103
+ };
104
+ } finally {
105
+ clearTimeout(timeout);
72
106
  }
73
- const maxBytes = options.maxBytes ?? DEFAULT_PAGE_MAX_BYTES;
74
- const body = await readResponseBytes(
75
- response,
76
- maxBytes,
77
- options.truncate === true
78
- );
79
- const contentType = response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
80
- return {
81
- url: url.toString(),
82
- status: response.status,
83
- contentType,
84
- bytes: body.bytes,
85
- truncated: body.truncated
86
- };
87
- }
88
- }
89
- async fetchOnce(url, accept) {
90
- const controller = new AbortController();
91
- const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
92
- try {
93
- return await this.fetchImpl(url, {
94
- redirect: "manual",
95
- signal: controller.signal,
96
- headers: {
97
- "user-agent": USER_AGENT,
98
- accept: accept ?? "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
99
- }
100
- });
101
- } finally {
102
- clearTimeout(timeout);
103
107
  }
104
108
  }
105
109
  async validate(url) {
@@ -1382,7 +1386,7 @@ async function probeGoogleFonts(fetcher, family) {
1382
1386
  );
1383
1387
  return response.status === 200 ? "available" : "inconclusive";
1384
1388
  } catch (error) {
1385
- return /HTTP 400\b/.test(messageOf2(error)) ? "unavailable" : "inconclusive";
1389
+ return /HTTP 400\b/.test(messageOf(error)) ? "unavailable" : "inconclusive";
1386
1390
  }
1387
1391
  }
1388
1392
  function googleFontForSlot(signal, assumption) {
@@ -1396,7 +1400,7 @@ function googleFontForSlot(signal, assumption) {
1396
1400
  function stripCssComments(css) {
1397
1401
  return css.replace(/\/\*[\s\S]*?\*\//g, "");
1398
1402
  }
1399
- function messageOf2(error) {
1403
+ function messageOf(error) {
1400
1404
  return error instanceof Error ? error.message : String(error);
1401
1405
  }
1402
1406
  var CONFIDENCE_FIELDS = [
@@ -1861,7 +1865,7 @@ async function extractBrandFromUrl(inputUrl, options = {}) {
1861
1865
  maxBytes: DEFAULT_PAGE_MAX_BYTES
1862
1866
  });
1863
1867
  } catch (error) {
1864
- warnings.push(`Could not fetch page ${sourceUrl}: ${messageOf22(error)}`);
1868
+ warnings.push(`Could not fetch page ${sourceUrl}: ${messageOf2(error)}`);
1865
1869
  warnings.push(
1866
1870
  `No usable brand color found; using ${defaultPrimaryColor}.`
1867
1871
  );
@@ -1923,7 +1927,7 @@ async function extractBrandFromUrl(inputUrl, options = {}) {
1923
1927
  });
1924
1928
  } catch (error) {
1925
1929
  warnings.push(
1926
- `Could not fetch stylesheet ${stylesheetUrl}: ${messageOf22(error)}`
1930
+ `Could not fetch stylesheet ${stylesheetUrl}: ${messageOf2(error)}`
1927
1931
  );
1928
1932
  }
1929
1933
  }
@@ -1961,7 +1965,7 @@ async function extractBrandFromUrl(inputUrl, options = {}) {
1961
1965
  });
1962
1966
  }
1963
1967
  } catch (error) {
1964
- warnings.push(`Rendered brand fallback failed: ${messageOf22(error)}`);
1968
+ warnings.push(`Rendered brand fallback failed: ${messageOf2(error)}`);
1965
1969
  }
1966
1970
  }
1967
1971
  const text = extractBrandText(analyzedHtml, pageUrl);
@@ -2106,7 +2110,7 @@ async function fetchManifestThemeColor(fetcher, manifestUrl, warnings) {
2106
2110
  const parsed = JSON.parse(manifest.text);
2107
2111
  return typeof parsed.theme_color === "string" ? parsed.theme_color : void 0;
2108
2112
  } catch (error) {
2109
- warnings.push(`Could not fetch manifest ${manifestUrl}: ${messageOf22(error)}`);
2113
+ warnings.push(`Could not fetch manifest ${manifestUrl}: ${messageOf2(error)}`);
2110
2114
  return void 0;
2111
2115
  }
2112
2116
  }
@@ -2116,7 +2120,7 @@ async function maybeFetchAsset(fetcher, candidate, kind, warnings) {
2116
2120
  return { ...downloaded, source: candidate.source };
2117
2121
  } catch (error) {
2118
2122
  warnings.push(
2119
- `Could not download ${kind} ${candidate.url}: ${messageOf22(error)}`
2123
+ `Could not download ${kind} ${candidate.url}: ${messageOf2(error)}`
2120
2124
  );
2121
2125
  return void 0;
2122
2126
  }
@@ -2128,21 +2132,115 @@ function cleanOption(value) {
2128
2132
  const cleaned = value?.trim();
2129
2133
  return cleaned && cleaned.length > 0 ? cleaned : void 0;
2130
2134
  }
2131
- function messageOf22(error) {
2135
+ function messageOf2(error) {
2132
2136
  return error instanceof Error ? error.message : String(error);
2133
2137
  }
2138
+ function starterFonts() {
2139
+ return {
2140
+ body: { family: "Instrument Sans", weights: [400, 500, 600] },
2141
+ heading: { family: "Bricolage Grotesque", weights: [500, 600, 700] },
2142
+ mono: { family: "IBM Plex Mono", weights: [400, 500] }
2143
+ };
2144
+ }
2145
+ var yamlString = (value) => JSON.stringify(value);
2146
+ function indexPageMdx(name, description) {
2147
+ return `---
2148
+ title: ${yamlString(`Welcome to ${name}`)}
2149
+ description: ${yamlString(description)}
2150
+ ---
2151
+
2152
+ <Note>
2153
+ This site was scaffolded with SaturnDocs. Edit \`docs.json\` to update site metadata and navigation.
2154
+ </Note>
2155
+
2156
+ ## Start here
2157
+
2158
+ <Columns cols={2}>
2159
+ <Card title="Write pages" icon="file-text">
2160
+ Add MDX files under \`pages/\`, then list them in \`docs.json\`.
2161
+ </Card>
2162
+ <Card title="Check your changes" icon="circle-check">
2163
+ Run \`saturndocs validate\` and \`saturndocs lint\` before you push.
2164
+ </Card>
2165
+ </Columns>
2166
+ `;
2167
+ }
2168
+ function quickstartPageMdx(name) {
2169
+ return `---
2170
+ title: Quickstart
2171
+ description: ${yamlString(`Start editing ${name}.`)}
2172
+ ---
2173
+
2174
+ ## Check the site
2175
+
2176
+ Run both checks from the docs folder before you push.
2177
+
2178
+ \`\`\`sh
2179
+ saturndocs validate
2180
+ saturndocs lint
2181
+ \`\`\`
2182
+
2183
+ ## Edit content
2184
+
2185
+ Update \`pages/index.mdx\`, then add more files under \`pages/\`. Every page that should appear in the sidebar must be listed in \`docs.json\`.
2186
+
2187
+ \`\`\`json title="docs.json"
2188
+ {
2189
+ "navigation": {
2190
+ "groups": [
2191
+ { "group": "Getting started", "pages": ["index", "quickstart"] }
2192
+ ]
2193
+ }
2194
+ }
2195
+ \`\`\`
2196
+
2197
+ ## Use built-in components
2198
+
2199
+ \`\`\`mdx
2200
+ <Note>
2201
+ Use notes for short callouts.
2202
+ </Note>
2203
+
2204
+ <Steps>
2205
+ <Step title="Create a page">
2206
+ Save a new MDX file in the pages directory.
2207
+ </Step>
2208
+ <Step title="Add it to navigation">
2209
+ Add the page slug to docs.json.
2210
+ </Step>
2211
+ </Steps>
2212
+ \`\`\`
2213
+ `;
2214
+ }
2215
+ function starterPages(name, description) {
2216
+ return [
2217
+ { path: "pages/index.mdx", content: indexPageMdx(name, description) },
2218
+ { path: "pages/quickstart.mdx", content: quickstartPageMdx(name) }
2219
+ ];
2220
+ }
2134
2221
 
2135
2222
  // src/commands/init.ts
2136
2223
  import pc from "picocolors";
2224
+ var DocsJsonExistsError = class extends Error {
2225
+ };
2137
2226
  function registerInit(program) {
2138
- program.command("init").description("Scaffold a new SaturnDocs docs project").argument("[dir]", "directory to scaffold", ".").option("--name <name>", "site name").option("--primary <css-color>", "primary brand color").option("--from-url <url>", "extract brand details from a website").option("--yes", "accepted for future interactive prompts").action(async (dir, options) => {
2227
+ program.command("init").description("Scaffold a new SaturnDocs docs project").argument("[dir]", "directory to scaffold", ".").option("--name <name>", "site name").option("--primary <css-color>", "primary brand color").option("--from-url <url>", "extract brand details from a website").option("--yes", "accepted for future interactive prompts").action(async (dir, options, self) => {
2228
+ const globals = resolveGlobalOptions(self);
2229
+ const writer = createResultWriter({ json: globals.json });
2230
+ const context = { command: "init", siteId: null };
2139
2231
  try {
2140
- const result = await scaffoldDocsProject(dir, options);
2141
- if (result.extraction) printExtractionReport(result);
2142
- printNextSteps(result.docsDir);
2232
+ const result = await scaffoldDocsProject(dir, options).catch((error) => {
2233
+ throw error instanceof DocsJsonExistsError ? invalidInput(error.message) : error;
2234
+ });
2235
+ const steps = nextSteps(result.docsDir);
2236
+ if (!globals.json) {
2237
+ if (result.extraction) printExtractionReport(result);
2238
+ printNextSteps(result.docsDir, steps);
2239
+ return;
2240
+ }
2241
+ process.exitCode = writer.write(successResult(context, initReport(result, steps)));
2143
2242
  } catch (error) {
2144
- console.error(pc.red(`error: ${messageOf(error)}`));
2145
- process.exit(1);
2243
+ process.exitCode = writer.write(failureResult(error, context));
2146
2244
  }
2147
2245
  });
2148
2246
  }
@@ -2150,12 +2248,12 @@ async function scaffoldDocsProject(dir = ".", options = {}, dependencies = {}) {
2150
2248
  const docsDir = resolve(dir);
2151
2249
  const docsJsonPath = join(docsDir, "docs.json");
2152
2250
  if (existsSync(docsJsonPath)) {
2153
- throw new Error(`docs.json already exists in ${docsDir}`);
2251
+ throw new DocsJsonExistsError(`docs.json already exists in ${docsDir}`);
2154
2252
  }
2155
2253
  await mkdir(docsDir, { recursive: true });
2156
2254
  const extractBrand = dependencies.extractBrand ?? extractBrandFromUrl;
2157
2255
  const extraction = options.fromUrl ? await extractBrand(options.fromUrl) : void 0;
2158
- if (extraction) await writeExtractedAssets(docsDir, extraction);
2256
+ const files = extraction ? await writeExtractedAssets(docsDir, extraction) : [];
2159
2257
  const defaultName = basename(docsDir) || "docs";
2160
2258
  const name = cleanOption2(options.name) ?? extraction?.name ?? defaultName;
2161
2259
  const primary = cleanOption2(options.primary) ?? extraction?.primaryColor ?? DEFAULT_PRIMARY_COLOR;
@@ -2167,8 +2265,8 @@ async function scaffoldDocsProject(dir = ".", options = {}, dependencies = {}) {
2167
2265
  }
2168
2266
  );
2169
2267
  config.fonts = extraction ? mergeExtractedFonts(extraction) : starterFonts();
2170
- await writeScaffoldFiles(docsDir, config);
2171
- return { docsDir, config: await loadDocsConfig(docsJsonPath), extraction };
2268
+ files.push(...await writeScaffoldFiles(docsDir, config));
2269
+ return { docsDir, config: await loadDocsConfig(docsJsonPath), extraction, files };
2172
2270
  }
2173
2271
  function buildDocsConfig(input) {
2174
2272
  const config = deriveDocsJson(
@@ -2187,13 +2285,6 @@ function buildDocsConfig(input) {
2187
2285
  if (input.favicon) config.favicon = input.favicon;
2188
2286
  return config;
2189
2287
  }
2190
- function starterFonts() {
2191
- return {
2192
- body: { family: "Instrument Sans", weights: [400, 500, 600] },
2193
- heading: { family: "Bricolage Grotesque", weights: [500, 600, 700] },
2194
- mono: { family: "IBM Plex Mono", weights: [400, 500] }
2195
- };
2196
- }
2197
2288
  function mergeExtractedFonts(extraction) {
2198
2289
  const fonts = starterFonts();
2199
2290
  const body = extraction.fonts?.body;
@@ -2233,104 +2324,83 @@ function cleanOption2(value) {
2233
2324
  return cleaned && cleaned.length > 0 ? cleaned : void 0;
2234
2325
  }
2235
2326
  async function writeScaffoldFiles(docsDir, config) {
2236
- const pagesDir = join(docsDir, "pages");
2237
- await mkdir(pagesDir, { recursive: true });
2327
+ await mkdir(join(docsDir, "pages"), { recursive: true });
2238
2328
  await writeFile(
2239
2329
  join(docsDir, "docs.json"),
2240
2330
  `${JSON.stringify(config, null, 2)}
2241
2331
  `,
2242
2332
  "utf8"
2243
2333
  );
2244
- await writeFile(
2245
- join(pagesDir, "index.mdx"),
2246
- indexPageMdx(config.name, config.description ?? ""),
2247
- "utf8"
2248
- );
2249
- await writeFile(
2250
- join(pagesDir, "quickstart.mdx"),
2251
- quickstartPageMdx(config.name),
2252
- "utf8"
2253
- );
2254
- }
2255
- async function writeExtractedAssets(docsDir, extraction) {
2256
- const assets = [extraction.logo, extraction.favicon].filter(
2257
- (asset) => asset !== void 0
2258
- );
2259
- if (assets.length === 0) return;
2260
- const publicDir = join(docsDir, "public");
2261
- await mkdir(publicDir, { recursive: true });
2262
- for (const asset of assets) {
2263
- await writeFile(join(publicDir, asset.suggestedFilename), asset.bytes);
2334
+ const written = ["docs.json"];
2335
+ for (const file of starterPages(config.name, config.description ?? "")) {
2336
+ await writeFile(join(docsDir, file.path), file.content, "utf8");
2337
+ written.push(file.path);
2338
+ }
2339
+ try {
2340
+ await writeFile(join(docsDir, "AGENTS.md"), AGENT_INSTRUCTIONS, { encoding: "utf8", flag: "wx" });
2341
+ written.push("AGENTS.md");
2342
+ } catch (error) {
2343
+ if (error.code !== "EEXIST") throw error;
2264
2344
  }
2345
+ return written;
2265
2346
  }
2266
- function indexPageMdx(name, description) {
2267
- return `---
2268
- title: ${yamlString(`Welcome to ${name}`)}
2269
- description: ${yamlString(description)}
2270
- ---
2271
-
2272
- <Note>
2273
- This site was scaffolded with SaturnDocs. Edit \`docs.json\` to update site metadata and navigation.
2274
- </Note>
2347
+ var AGENT_INSTRUCTIONS = `# Instructions for coding agents
2275
2348
 
2276
- ## Start here
2349
+ This directory is the source of a SaturnDocs site. SaturnDocs builds and publishes the site from Git: a push to the connected repository starts a build.
2277
2350
 
2278
- <Columns cols={2}>
2279
- <Card title="Write pages" icon="file-text">
2280
- Add MDX files under \`pages/\`, then list them in \`docs.json\`.
2281
- </Card>
2282
- <Card title="Preview locally" icon="monitor">
2283
- Run \`saturndocs dev\` to open the docs site while you edit.
2284
- </Card>
2285
- </Columns>
2286
- `;
2287
- }
2288
- function quickstartPageMdx(name) {
2289
- return `---
2290
- title: Quickstart
2291
- description: ${yamlString(`Start editing ${name}.`)}
2292
- ---
2351
+ ## Layout
2293
2352
 
2294
- ## Run the site
2353
+ - \`docs.json\`: site settings and navigation.
2354
+ - \`pages/\`: one \`.md\` or \`.mdx\` file per page. Each page needs a \`title\` in its frontmatter.
2355
+ - \`public/\`: images and other files, served from the site root.
2356
+ - \`openapi/\`: OpenAPI specifications.
2295
2357
 
2296
- \`\`\`sh
2297
- saturndocs dev
2298
- \`\`\`
2358
+ Any other file in this directory stops the publish. This file and \`CLAUDE.md\` are the exceptions: SaturnDocs accepts them and never publishes them.
2299
2359
 
2300
- ## Edit content
2360
+ ## Before every commit
2301
2361
 
2302
- Update \`pages/index.mdx\`, then add more files under \`pages/\`. Every page that should appear in the sidebar must be listed in \`docs.json\`.
2362
+ Run both checks from this directory and fix every error they report. Each error names a file, a line, a rule, and a fix.
2303
2363
 
2304
- \`\`\`json title="docs.json"
2305
- {
2306
- "navigation": {
2307
- "groups": [
2308
- { "group": "Getting started", "pages": ["index", "quickstart"] }
2309
- ]
2310
- }
2311
- }
2312
- \`\`\`
2313
-
2314
- ## Use built-in components
2315
-
2316
- \`\`\`mdx
2317
- <Note>
2318
- Use notes for short callouts.
2319
- </Note>
2320
-
2321
- <Steps>
2322
- <Step title="Create a page">
2323
- Save a new MDX file in the pages directory.
2324
- </Step>
2325
- <Step title="Add it to navigation">
2326
- Add the page slug to docs.json.
2327
- </Step>
2328
- </Steps>
2364
+ \`\`\`sh
2365
+ npx saturndocs validate . --json
2366
+ npx saturndocs lint . --json
2329
2367
  \`\`\`
2330
2368
  `;
2369
+ async function writeExtractedAssets(docsDir, extraction) {
2370
+ const assets = [extraction.logo, extraction.favicon].filter(
2371
+ (asset) => asset !== void 0
2372
+ );
2373
+ if (assets.length === 0) return [];
2374
+ const publicDir = join(docsDir, "public");
2375
+ await mkdir(publicDir, { recursive: true });
2376
+ const written = [];
2377
+ for (const asset of assets) {
2378
+ await writeFile(join(publicDir, asset.suggestedFilename), asset.bytes);
2379
+ written.push(`public/${asset.suggestedFilename}`);
2380
+ }
2381
+ return written;
2331
2382
  }
2332
- function yamlString(value) {
2333
- return JSON.stringify(value);
2383
+ function initReport(result, steps) {
2384
+ const extraction = result.extraction;
2385
+ const fonts = {};
2386
+ for (const slot of ["body", "heading", "mono"]) {
2387
+ const font = extraction?.fonts?.[slot];
2388
+ if (font) fonts[slot] = font.family;
2389
+ }
2390
+ return {
2391
+ docs_dir: result.docsDir,
2392
+ files: result.files,
2393
+ name: result.config.name,
2394
+ primary: result.config.colors.primary,
2395
+ extraction: extraction ? {
2396
+ description: result.config.description ?? null,
2397
+ logo: result.config.logo ?? null,
2398
+ favicon: result.config.favicon ?? null,
2399
+ fonts,
2400
+ warnings: [...extraction.warnings]
2401
+ } : null,
2402
+ next_steps: steps
2403
+ };
2334
2404
  }
2335
2405
  function printExtractionReport(result) {
2336
2406
  const extraction = result.extraction;
@@ -2403,18 +2473,31 @@ function printThemeReport(candidate, theme) {
2403
2473
  console.log(` omitted (not high confidence): ${omitted.join(", ")}`);
2404
2474
  }
2405
2475
  }
2406
- function printNextSteps(docsDir) {
2476
+ function nextSteps(docsDir) {
2477
+ const rel = relative(process.cwd(), docsDir);
2478
+ const cdTarget = !rel || rel === "." ? "" : rel.startsWith("..") ? docsDir : rel;
2479
+ return [
2480
+ ...cdTarget ? [`cd ${cdTarget}`] : [],
2481
+ "Edit pages/index.mdx and pages/quickstart.mdx to start writing.",
2482
+ "Edit docs.json to adjust navigation and site metadata.",
2483
+ "saturndocs validate",
2484
+ "saturndocs lint"
2485
+ ];
2486
+ }
2487
+ var STEP_NOTES = {
2488
+ "saturndocs validate": "Check docs.json, pages, and links.",
2489
+ "saturndocs lint": "Check page content."
2490
+ };
2491
+ function printNextSteps(docsDir, steps) {
2407
2492
  console.log(pc.green(`
2408
2493
  Created SaturnDocs docs in ${docsDir}`));
2409
2494
  console.log(pc.bold("Next steps"));
2410
- const rel = relative(process.cwd(), docsDir);
2411
- const cdTarget = !rel || rel === "." ? "" : rel.startsWith("..") ? docsDir : rel;
2412
- if (cdTarget) {
2413
- console.log(` ${pc.cyan(`cd ${cdTarget}`)}`);
2495
+ for (const step of steps) {
2496
+ const note = STEP_NOTES[step];
2497
+ if (note !== void 0) console.log(` ${pc.cyan(step.padEnd(20))} ${note}`);
2498
+ else if (step.startsWith("cd ")) console.log(` ${pc.cyan(step)}`);
2499
+ else console.log(` ${step}`);
2414
2500
  }
2415
- console.log(` ${pc.cyan("saturndocs dev")}`);
2416
- console.log(" Edit docs.json to adjust navigation and site metadata.");
2417
- console.log(" Edit pages/index.mdx and pages/quickstart.mdx to start writing.");
2418
2501
  }
2419
2502
  function truncate(value, maxLength) {
2420
2503
  if (value.length <= maxLength) return value;
@@ -2448,5 +2531,6 @@ export {
2448
2531
  registerInit,
2449
2532
  scaffoldDocsProject,
2450
2533
  buildDocsConfig,
2534
+ AGENT_INSTRUCTIONS,
2451
2535
  printExtractionReport
2452
2536
  };