{"version":3,"file":"bin.mjs","names":[],"sources":["../../src/cli/commands/build.ts","../../src/cli/log-level.ts","../../src/cli/commands/dev.ts","../../src/cli/init-fs.ts","../../src/cli/defaults.ts","../../src/cli/commands/init.ts","../../src/cli/commands/mcp.ts","../../src/cli/commands/preview.ts","../../src/cli/commands/validate.ts","../../src/cli/bin.ts"],"sourcesContent":["import type { Command } from \"cac\";\nimport { findPagesmithConfig, withConfigFlag } from \"@pagesmith/core/cli-kit\";\nimport { build } from \"../../site.js\";\n\ntype BuildOpts = {\n  config?: string;\n  outDir?: string;\n  basePath?: string;\n};\n\nexport function registerBuildCommand(command: Command): Command {\n  return withConfigFlag(command)\n    .option(\"--out-dir <path>\", \"Output directory (overrides config)\")\n    .option(\"--base-path <path>\", \"Base URL path prefix (overrides config)\")\n    .action(async (options: BuildOpts) => {\n      const { configPath } = findPagesmithConfig({ explicitPath: options.config });\n      await build({\n        configPath,\n        outDir: options.outDir,\n        basePath: options.basePath,\n      });\n    });\n}\n","export type LogLevel = \"silent\" | \"error\" | \"warn\" | \"info\" | \"verbose\";\n\nexport function parseLogLevel(input: string): LogLevel {\n  const normalized = input.trim().toLowerCase();\n  if (normalized === \"silent\") return \"silent\";\n  if (normalized === \"error\" || normalized === \"errors\") return \"error\";\n  if (normalized === \"warn\" || normalized === \"warning\" || normalized === \"warnings\") return \"warn\";\n  if (normalized === \"info\" || normalized === \"log\") return \"info\";\n  if (normalized === \"verbose\" || normalized === \"debug\") return \"verbose\";\n  throw new Error(\n    `--log-level must be one of: silent, error, warn, info, verbose (got \"${input}\")`,\n  );\n}\n\n/**\n * Parse a `--port` CLI value. Accepts the literal `\"auto\"` (case-insensitive)\n * to opt into the auto-port-discovery mode, an integer, or a numeric string.\n */\nexport function parsePort(input: number | string): number | \"auto\" {\n  if (typeof input === \"string\" && input.trim().toLowerCase() === \"auto\") {\n    return \"auto\";\n  }\n  const port = typeof input === \"number\" ? input : Number.parseInt(input, 10);\n  if (!Number.isFinite(port)) throw new Error('--port must be a valid number or \"auto\"');\n  if (port < 1 || port > 65535) throw new Error(\"--port must be between 1 and 65535\");\n  return port;\n}\n","import type { Command } from \"cac\";\nimport { findPagesmithConfig, withConfigFlag } from \"@pagesmith/core/cli-kit\";\nimport { startDev } from \"../../site.js\";\nimport { parseLogLevel, parsePort } from \"../log-level.js\";\n\ntype DevOpts = {\n  port?: number | string;\n  config?: string;\n  open?: boolean;\n  outDir?: string;\n  basePath?: string;\n  logLevel?: string;\n};\n\nexport function registerDevCommand(command: Command): Command {\n  return withConfigFlag(command)\n    .option(\n      \"-p, --port <number|auto>\",\n      'Server port. Use a number, or \"auto\" to scan upward from 4000 for the first free port (default: server.devPort, normally 3000).',\n    )\n    .option(\"--open\", \"Open browser on server start\")\n    .option(\"--out-dir <path>\", \"Output directory (overrides config)\")\n    .option(\"--base-path <path>\", \"Base URL path prefix (overrides config)\")\n    .option(\n      \"--log-level <level>\",\n      \"silent|error|warn|info|verbose (default: server.logLevel, normally info)\",\n    )\n    .action(async (options: DevOpts) => {\n      const { configPath } = findPagesmithConfig({ explicitPath: options.config });\n      await startDev({\n        configPath,\n        port: options.port == null ? undefined : parsePort(options.port),\n        open: options.open,\n        logLevel: options.logLevel ? parseLogLevel(options.logLevel) : undefined,\n        outDir: options.outDir,\n        basePath: options.basePath,\n      });\n    });\n}\n","import { existsSync, readFileSync, writeFileSync } from \"fs\";\nimport JSON5 from \"json5\";\nimport { dirname, relative, resolve } from \"path\";\nimport { isDeepStrictEqual } from \"util\";\nimport type { DocsUserConfig } from \"../config.js\";\n\nexport type InitAnswers = {\n  name: string;\n  title: string;\n  origin: string;\n  basePath: string;\n  contentDir: string;\n  copyrightStartYear: number;\n  search: boolean;\n  ai: boolean;\n  starterContent: boolean;\n};\n\nexport type DocsConfigDocument = DocsUserConfig & {\n  $schema?: string;\n};\n\nexport type UpdateInitConfigResult = {\n  changed: boolean;\n  created: boolean;\n  updated: boolean;\n  config: DocsConfigDocument;\n};\n\nconst DEFAULT_OUT_DIR = \"gh-pages\";\nconst DOCS_CONFIG_SCHEMA_PATH = [\n  \"node_modules\",\n  \"@pagesmith\",\n  \"docs\",\n  \"schemas\",\n  \"pagesmith-config.schema.json\",\n] as const;\n\nfunction hasOwn(value: unknown, key: string): boolean {\n  return (\n    typeof value === \"object\" && value !== null && Object.prototype.hasOwnProperty.call(value, key)\n  );\n}\n\nfunction normalizePath(value: string): string {\n  return value.replaceAll(\"\\\\\", \"/\");\n}\n\nfunction omitKnownInitKeys(config: DocsConfigDocument): DocsConfigDocument {\n  const {\n    $schema: _schema,\n    name: _name,\n    title: _title,\n    origin: _origin,\n    basePath: _basePath,\n    contentDir: _contentDir,\n    outDir: _outDir,\n    copyright: _copyright,\n    search: _search,\n    ...rest\n  } = config;\n\n  return rest;\n}\n\nfunction buildCopyrightConfig(\n  existingConfig: DocsConfigDocument | undefined,\n  answers: InitAnswers,\n): NonNullable<DocsUserConfig[\"copyright\"]> {\n  const existingCopyright = existingConfig?.copyright;\n  const shouldRefreshProjectName =\n    existingCopyright?.projectName == null ||\n    existingCopyright.projectName === existingConfig?.title ||\n    existingCopyright.projectName === existingConfig?.name;\n\n  return {\n    projectName: shouldRefreshProjectName ? answers.title : existingCopyright.projectName,\n    startYear: existingCopyright?.startYear ?? answers.copyrightStartYear,\n    endYear: hasOwn(existingCopyright ?? {}, \"endYear\")\n      ? (existingCopyright?.endYear ?? null)\n      : null,\n  };\n}\n\nfunction buildSearchConfig(\n  existingConfig: DocsConfigDocument | undefined,\n  answers: InitAnswers,\n): NonNullable<DocsUserConfig[\"search\"]> {\n  return existingConfig?.search\n    ? {\n        ...existingConfig.search,\n        enabled: answers.search,\n      }\n    : { enabled: answers.search };\n}\n\nexport function parseInitConfigFile(configPath: string): DocsConfigDocument | undefined {\n  if (!existsSync(configPath)) return undefined;\n\n  try {\n    return JSON5.parse(readFileSync(configPath, \"utf-8\")) as DocsConfigDocument;\n  } catch (err) {\n    const message = err instanceof Error ? err.message : String(err);\n    throw new Error(\n      `Failed to parse init config file: ${configPath}\\n` +\n        `  ${message}\\n` +\n        `  Check that the file contains valid JSON5 syntax before rerunning 'pagesmith init'.`,\n    );\n  }\n}\n\nexport function applyExistingConfigDefaults(\n  defaults: InitAnswers,\n  existingConfig: DocsConfigDocument | undefined,\n): InitAnswers {\n  if (!existingConfig) return defaults;\n\n  return {\n    ...defaults,\n    name: existingConfig.name ?? existingConfig.title ?? defaults.name,\n    title: existingConfig.title ?? existingConfig.name ?? defaults.title,\n    origin: existingConfig.origin ?? defaults.origin,\n    basePath: existingConfig.basePath ?? defaults.basePath,\n    contentDir: existingConfig.contentDir ?? defaults.contentDir,\n    copyrightStartYear: existingConfig.copyright?.startYear ?? defaults.copyrightStartYear,\n    search: existingConfig.search?.enabled ?? defaults.search,\n  };\n}\n\nexport function getDocsConfigSchemaRef(projectDir: string, configPath: string): string {\n  const absoluteSchemaPath = resolve(projectDir, ...DOCS_CONFIG_SCHEMA_PATH);\n  const relativeSchemaPath = normalizePath(relative(dirname(configPath), absoluteSchemaPath));\n  return relativeSchemaPath.startsWith(\".\") ? relativeSchemaPath : `./${relativeSchemaPath}`;\n}\n\nexport function buildInitConfigDocument(options: {\n  projectDir: string;\n  configPath: string;\n  answers: InitAnswers;\n  existingConfig?: DocsConfigDocument;\n}): DocsConfigDocument {\n  const { projectDir, configPath, answers, existingConfig } = options;\n  const extraConfig = existingConfig ? omitKnownInitKeys(existingConfig) : {};\n\n  return {\n    $schema: getDocsConfigSchemaRef(projectDir, configPath),\n    name: answers.name,\n    title: answers.title,\n    origin: answers.origin,\n    basePath: answers.basePath,\n    contentDir: answers.contentDir,\n    outDir: existingConfig?.outDir ?? DEFAULT_OUT_DIR,\n    copyright: buildCopyrightConfig(existingConfig, answers),\n    search: buildSearchConfig(existingConfig, answers),\n    ...extraConfig,\n  };\n}\n\nexport function stringifyInitConfig(config: DocsConfigDocument): string {\n  return `${JSON5.stringify(config, null, 2)}\\n`;\n}\n\nexport function updateInitConfigFile(options: {\n  projectDir: string;\n  configPath: string;\n  answers: InitAnswers;\n}): UpdateInitConfigResult {\n  const existingConfig = parseInitConfigFile(options.configPath);\n  const nextConfig = buildInitConfigDocument({\n    ...options,\n    existingConfig,\n  });\n\n  if (existingConfig && isDeepStrictEqual(existingConfig, nextConfig)) {\n    return {\n      changed: false,\n      created: false,\n      updated: false,\n      config: nextConfig,\n    };\n  }\n\n  writeFileSync(options.configPath, stringifyInitConfig(nextConfig));\n\n  return {\n    changed: true,\n    created: !existingConfig,\n    updated: Boolean(existingConfig),\n    config: nextConfig,\n  };\n}\n","/**\n * Read prompt defaults for `pagesmith-docs init` (and surfaces dev/build/preview\n * options where useful) from any supported `pagesmith.config.{ts,...}` file.\n *\n * Goes through `loadPagesmithConfig` from `@pagesmith/core/cli-kit` so users\n * can author their config in JSON5 today and graduate to TypeScript later\n * without changing the CLI surface.\n */\n\nimport { basename } from \"path\";\nimport { findPagesmithConfig, loadPagesmithConfig } from \"@pagesmith/core/cli-kit\";\nimport {\n  detectFirstCommitYear,\n  detectGitOrigin,\n  resolveInitOrigin,\n  toTitleCase,\n} from \"../config.js\";\nimport type { DocsUserConfig } from \"../config.js\";\nimport { existsSync, readFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport type { InitAnswers } from \"./init-fs.js\";\nimport { applyExistingConfigDefaults } from \"./init-fs.js\";\n\nfunction readPackageName(projectDir: string): string | undefined {\n  try {\n    const pkg = JSON.parse(readFileSync(resolve(projectDir, \"package.json\"), \"utf-8\")) as {\n      name?: string;\n    };\n    return pkg.name?.replace(/^@[^/]+\\//, \"\");\n  } catch {\n    return undefined;\n  }\n}\n\nexport type ResolvedInitDefaults = {\n  /** Detected/merged answers used as prompt defaults. */\n  defaults: InitAnswers;\n  /**\n   * Path to the existing config file (if any) and its format. The docs init\n   * command writes back to this path so users keep authoring in their chosen\n   * format. JSON5/JSON files round-trip cleanly; .ts/.js/.mjs files are kept\n   * read-only by init (the user owns code-shaped configs).\n   */\n  configPath: string;\n  configIsCode: boolean;\n  hasPackageJson: boolean;\n};\n\nexport async function resolveInitDefaults(options: {\n  projectDir: string;\n  configPath?: string;\n}): Promise<ResolvedInitDefaults> {\n  const { projectDir } = options;\n  const gitInfo = detectGitOrigin(projectDir);\n  const pkgName = readPackageName(projectDir);\n  const name = gitInfo?.repoName ?? pkgName ?? basename(projectDir);\n  const basePath = gitInfo?.basePath ?? `/${name}`;\n  const origin =\n    (await resolveInitOrigin(projectDir, gitInfo)) ?? gitInfo?.origin ?? \"https://example.com\";\n  const copyrightStartYear = detectFirstCommitYear(projectDir) ?? new Date().getFullYear();\n\n  let defaults: InitAnswers = {\n    name,\n    title: toTitleCase(name),\n    origin,\n    basePath,\n    contentDir: \"docs\",\n    copyrightStartYear,\n    search: true,\n    ai: false,\n    starterContent: true,\n  };\n\n  // Look for an existing config — explicit --config path wins, otherwise\n  // auto-discover using the unified loader's resolution order.\n  const found = findPagesmithConfig({ cwd: projectDir, explicitPath: options.configPath });\n  let resolvedConfigPath = found.configPath;\n  let configIsCode = false;\n\n  if (found.configPath && found.format) {\n    const loaded = await loadPagesmithConfig({\n      cwd: projectDir,\n      explicitPath: found.configPath,\n    });\n    if (loaded.config) {\n      defaults = applyExistingConfigDefaults(defaults, loaded.config as DocsUserConfig);\n    }\n    configIsCode =\n      found.format === \"ts\" ||\n      found.format === \"mts\" ||\n      found.format === \"js\" ||\n      found.format === \"mjs\";\n  }\n\n  // When no config exists yet, default to writing pagesmith.config.json5 next\n  // to the project so init produces something the schema can validate.\n  if (!resolvedConfigPath) {\n    resolvedConfigPath = resolve(projectDir, \"pagesmith.config.json5\");\n  }\n\n  return {\n    defaults,\n    configPath: resolvedConfigPath,\n    configIsCode,\n    hasPackageJson: existsSync(resolve(projectDir, \"package.json\")),\n  };\n}\n","import type { Command } from \"cac\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport {\n  assertValue,\n  intro,\n  log,\n  note,\n  outro,\n  promptConfirm,\n  promptText,\n  resolveInteractive,\n  spinner,\n  tasks,\n  withConfigFlag,\n  withInteractivityFlags,\n} from \"@pagesmith/core/cli-kit\";\nimport { toTitleCase } from \"../../config.js\";\nimport { resolveInitDefaults } from \"../defaults.js\";\nimport { type InitAnswers, updateInitConfigFile } from \"../init-fs.js\";\n\ntype InitOpts = {\n  ai?: boolean;\n  config?: string;\n  name?: string;\n  title?: string;\n  origin?: string;\n  basePath?: string;\n  contentDir?: string;\n  search?: boolean;\n  starterContent?: boolean;\n  yes?: boolean;\n  nonInteractive?: boolean;\n  interactive?: boolean;\n  llms?: boolean;\n};\n\nfunction scriptCommand(command: \"dev\" | \"build\" | \"preview\", configPath?: string): string {\n  const base = `pagesmith-docs ${command}`;\n  if (!configPath || configPath === \"pagesmith.config.json5\") return base;\n  return `${base} --config ${configPath}`;\n}\n\nfunction ensureDocsScripts(projectDir: string, configPath?: string): string[] {\n  const pkgPath = resolve(projectDir, \"package.json\");\n  if (!existsSync(pkgPath)) return [];\n\n  try {\n    const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as {\n      scripts?: Record<string, string>;\n    };\n    const scripts = { ...(pkg.scripts ?? {}) };\n    const desired = {\n      \"docs:dev\": scriptCommand(\"dev\", configPath),\n      \"docs:build\": scriptCommand(\"build\", configPath),\n      \"docs:preview\": scriptCommand(\"preview\", configPath),\n    };\n    const created: string[] = [];\n    let changed = false;\n\n    for (const [name, value] of Object.entries(desired)) {\n      if (!scripts[name]) {\n        scripts[name] = value;\n        created.push(`package.json#scripts.${name}`);\n        changed = true;\n      }\n    }\n\n    if (!changed) return created;\n\n    pkg.scripts = scripts;\n    writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n    return created;\n  } catch {\n    return [];\n  }\n}\n\nfunction writeIfMissing(filePath: string, content: string): boolean {\n  if (existsSync(filePath)) return false;\n  writeFileSync(filePath, content);\n  return true;\n}\n\nconst STARTER_FILES: Array<{ rel: string; content: (answers: InitAnswers) => string }> = [\n  {\n    rel: \"README.md\",\n    content: (a) =>\n      [\n        \"---\",\n        `title: ${a.title}`,\n        `tagline: Welcome to ${a.title}`,\n        `description: ${a.title} documentation`,\n        \"actions:\",\n        \"  - text: Get Started\",\n        \"    link: /guide/getting-started\",\n        \"    theme: brand\",\n        \"  - text: Reference\",\n        \"    link: /reference/overview\",\n        \"    theme: alt\",\n        \"features:\",\n        \"  - title: Convention-based docs\",\n        \"    details: Organize docs with folders, README.md pages, and meta.json5 ordering.\",\n        \"  - title: GitHub Pages friendly\",\n        \"    details: Defaults to a GitHub Pages base path using the repo name.\",\n        \"---\",\n        \"\",\n        \"# Welcome\",\n        \"\",\n        \"Start from the guide, then expand the reference as your project grows.\",\n        \"\",\n      ].join(\"\\n\"),\n  },\n  {\n    rel: \"guide/meta.json5\",\n    content: () =>\n      [\n        \"{\",\n        \"  displayName: 'Guide',\",\n        \"  orderBy: 'manual',\",\n        \"  items: ['getting-started', 'configuration'],\",\n        \"}\",\n        \"\",\n      ].join(\"\\n\"),\n  },\n  {\n    rel: \"guide/README.md\",\n    content: () =>\n      [\n        \"---\",\n        \"title: Guide\",\n        \"description: Start here to learn how this project is documented.\",\n        \"---\",\n        \"\",\n        \"# Guide\",\n        \"\",\n        \"Use this section for onboarding, setup, and configuration walkthroughs.\",\n        \"\",\n      ].join(\"\\n\"),\n  },\n  {\n    rel: \"guide/getting-started/README.md\",\n    content: () =>\n      [\n        \"---\",\n        \"title: Getting Started\",\n        \"description: Learn the basics of this project and its docs site.\",\n        \"---\",\n        \"\",\n        \"# Getting Started\",\n        \"\",\n        \"Explain how to install, run, and explore the project here.\",\n        \"\",\n      ].join(\"\\n\"),\n  },\n  {\n    rel: \"guide/configuration/README.md\",\n    content: () =>\n      [\n        \"---\",\n        \"title: Configuration\",\n        \"description: Document the key configuration and setup decisions for this project.\",\n        \"---\",\n        \"\",\n        \"# Configuration\",\n        \"\",\n        \"Document environment variables, config files, and deployment expectations here.\",\n        \"\",\n      ].join(\"\\n\"),\n  },\n  {\n    rel: \"reference/meta.json5\",\n    content: () =>\n      [\n        \"{\",\n        \"  displayName: 'Reference',\",\n        \"  orderBy: 'manual',\",\n        \"  items: ['overview', 'api'],\",\n        \"}\",\n        \"\",\n      ].join(\"\\n\"),\n  },\n  {\n    rel: \"reference/README.md\",\n    content: () =>\n      [\n        \"---\",\n        \"title: Reference\",\n        \"description: API and implementation reference for this project.\",\n        \"---\",\n        \"\",\n        \"# Reference\",\n        \"\",\n        \"Use this section for API details, commands, and integration notes.\",\n        \"\",\n      ].join(\"\\n\"),\n  },\n  {\n    rel: \"reference/overview/README.md\",\n    content: () =>\n      [\n        \"---\",\n        \"title: Overview\",\n        \"description: A high-level reference map for the project.\",\n        \"---\",\n        \"\",\n        \"# Overview\",\n        \"\",\n        \"Summarize the major modules, packages, or subsystems here.\",\n        \"\",\n      ].join(\"\\n\"),\n  },\n  {\n    rel: \"reference/api/README.md\",\n    content: () =>\n      [\n        \"---\",\n        \"title: API\",\n        \"description: Public API reference for this project.\",\n        \"---\",\n        \"\",\n        \"# API\",\n        \"\",\n        \"List commands, exports, endpoints, or interfaces here.\",\n        \"\",\n      ].join(\"\\n\"),\n  },\n];\n\nasync function promptInteractive(defaults: InitAnswers, version: string): Promise<InitAnswers> {\n  intro(`Pagesmith Docs v${version}`);\n\n  const name = await promptText({\n    message: \"Project name\",\n    placeholder: defaults.name,\n    defaultValue: defaults.name,\n  });\n  const titleFallback =\n    defaults.title === toTitleCase(defaults.name) ? toTitleCase(name) : defaults.title;\n  const title = await promptText({\n    message: \"Site title\",\n    placeholder: titleFallback,\n    defaultValue: titleFallback,\n  });\n  const origin = await promptText({\n    message: \"Site origin\",\n    placeholder: defaults.origin,\n    defaultValue: defaults.origin,\n  });\n  const basePath = await promptText({\n    message: \"Base path\",\n    placeholder: defaults.basePath,\n    defaultValue: defaults.basePath,\n  });\n  const contentDir = await promptText({\n    message: \"Content directory\",\n    placeholder: defaults.contentDir,\n    defaultValue: defaults.contentDir,\n  });\n  const search = await promptConfirm({\n    message: \"Enable search?\",\n    initialValue: defaults.search,\n  });\n  const ai = await promptConfirm({\n    message: \"Install AI integrations?\",\n    initialValue: defaults.ai,\n  });\n  const starterContent = await promptConfirm({\n    message: \"Create starter content?\",\n    initialValue: defaults.starterContent,\n  });\n\n  return {\n    name,\n    title,\n    origin,\n    basePath,\n    contentDir,\n    copyrightStartYear: defaults.copyrightStartYear,\n    search,\n    ai,\n    starterContent,\n  };\n}\n\nexport function registerInitCommand(command: Command, version: string): Command {\n  return withConfigFlag(withInteractivityFlags(command))\n    .option(\"--ai\", \"Install AI integrations (skills, guidelines)\")\n    .option(\"--no-llms\", \"Skip llms.txt / llms-full.txt generation during AI install\")\n    .option(\"--name <value>\", \"Project name used in docs metadata\")\n    .option(\"--title <value>\", \"Site title used in docs metadata\")\n    .option(\"--origin <url>\", \"Canonical site origin (default: detected GitHub Pages host)\")\n    .option(\"--base-path <path>\", \"Base URL path (default: /<repo-name>)\")\n    .option(\"--content-dir <path>\", \"Docs content directory (default: docs)\")\n    .option(\"--search\", \"Enable built-in search\")\n    .option(\"--no-search\", \"Disable built-in search\")\n    .option(\"--starter-content\", \"Create starter guide/reference pages\")\n    .option(\"--no-starter-content\", \"Skip starter content\")\n    .action(async (options: InitOpts) => {\n      const projectDir = resolve(\".\");\n      const { interactive, reason } = resolveInteractive(options);\n\n      // Spinner around git/network probing keeps the CLI responsive even\n      // when the optional GitHub Pages origin probe is slow.\n      const detectSpinner = spinner();\n      detectSpinner.start(\"Inspecting project (git, package.json, existing config)…\");\n      let resolved;\n      try {\n        resolved = await resolveInitDefaults({\n          projectDir,\n          configPath: options.config,\n        });\n      } catch (err) {\n        detectSpinner.error(\"Failed to inspect project\");\n        throw err;\n      }\n      detectSpinner.stop(\"Project inspected\");\n\n      const merged: InitAnswers = { ...resolved.defaults };\n      if (options.name) merged.name = options.name;\n      if (options.title) merged.title = options.title;\n      if (options.origin) merged.origin = options.origin;\n      if (options.basePath) merged.basePath = options.basePath;\n      if (options.contentDir) merged.contentDir = options.contentDir;\n      if (typeof options.search === \"boolean\") merged.search = options.search;\n      if (typeof options.starterContent === \"boolean\")\n        merged.starterContent = options.starterContent;\n      if (options.ai) merged.ai = true;\n\n      let answers: InitAnswers;\n      if (interactive) {\n        answers = await promptInteractive(merged, version);\n      } else {\n        log.info(`Running non-interactively (${reason}); using detected defaults.`);\n        // Strict mode: fail loudly if required values aren't satisfiable.\n        merged.name = assertValue(merged.name, {\n          label: \"Project name\",\n          flag: \"--name\",\n          configKey: \"name\",\n        });\n        merged.origin = assertValue(merged.origin, {\n          label: \"Site origin\",\n          flag: \"--origin\",\n          configKey: \"origin\",\n        });\n        merged.basePath = assertValue(merged.basePath, {\n          label: \"Base path\",\n          flag: \"--base-path\",\n          configKey: \"basePath\",\n        });\n        answers = merged;\n      }\n\n      if (resolved.configIsCode) {\n        log.warn(\n          `Detected ${resolved.configPath} (TypeScript/JS config). Init writes back to JSON5 only.`,\n        );\n        log.warn(\"Update your TS/JS config manually to match the answers above.\");\n      }\n\n      const created: string[] = [];\n      const updated: string[] = [];\n\n      const fsTasks: Parameters<typeof tasks>[0] = [];\n\n      // 1. Config file: write JSON5 form (TS/JS configs are user-owned and\n      //    will not be re-emitted by init; the warning above already covers it).\n      const writableConfigPath =\n        resolved.configIsCode || resolved.configPath.endsWith(\".json5\")\n          ? resolved.configPath\n          : resolved.configPath;\n      // Skip the actual config write when source is a TS/JS file the user owns.\n      if (!resolved.configIsCode) {\n        fsTasks.push({\n          title: \"Write pagesmith config\",\n          task: async () => {\n            const result = updateInitConfigFile({\n              projectDir,\n              configPath: writableConfigPath,\n              answers,\n            });\n            if (result.created) {\n              created.push(writableConfigPath);\n              return \"Created config\";\n            }\n            if (result.updated) {\n              updated.push(writableConfigPath);\n              return \"Updated config\";\n            }\n            return \"Config already up to date\";\n          },\n        });\n      }\n\n      // 2. package.json scripts\n      fsTasks.push({\n        title: \"Ensure docs:* scripts in package.json\",\n        task: async () => {\n          const entries = ensureDocsScripts(projectDir, writableConfigPath);\n          created.push(...entries);\n          return entries.length === 0 ? \"No script changes needed\" : `Added ${entries.length}`;\n        },\n      });\n\n      // 3. Content directories + starter files\n      fsTasks.push({\n        title: \"Scaffold content directory\",\n        task: async () => {\n          const contentRoot = resolve(answers.contentDir);\n          const dirs = [\n            contentRoot,\n            resolve(contentRoot, \"guide\"),\n            resolve(contentRoot, \"reference\"),\n            resolve(contentRoot, \"guide\", \"getting-started\"),\n            resolve(contentRoot, \"guide\", \"configuration\"),\n            resolve(contentRoot, \"reference\", \"overview\"),\n            resolve(contentRoot, \"reference\", \"api\"),\n          ];\n          for (const dir of dirs) {\n            if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n          }\n          if (!answers.starterContent) return \"Skipped starter files\";\n\n          for (const file of STARTER_FILES) {\n            const filePath = resolve(contentRoot, file.rel);\n            if (writeIfMissing(filePath, file.content(answers))) {\n              created.push(`${answers.contentDir}/${file.rel}`);\n            }\n          }\n          return \"Starter files written\";\n        },\n      });\n\n      // 4. AI integrations (optional)\n      if (answers.ai) {\n        fsTasks.push({\n          title: \"Install AI integrations\",\n          task: async () => {\n            const { installAiArtifacts } = await import(\"@pagesmith/core/ai\");\n            const results = installAiArtifacts({\n              assistants: \"all\",\n              scope: \"project\",\n              profile: \"docs\",\n              includeLlms: options.llms !== false,\n            });\n            for (const result of results) {\n              created.push(result.path);\n            }\n            return `${results.length} artifact(s) installed`;\n          },\n        });\n      }\n\n      await tasks(fsTasks);\n\n      const summaryLines: string[] = [];\n      if (created.length > 0) {\n        summaryLines.push(\"Created:\");\n        summaryLines.push(...created.map((file) => `  ${file}`));\n      }\n      if (updated.length > 0) {\n        if (summaryLines.length > 0) summaryLines.push(\"\");\n        summaryLines.push(\"Updated:\");\n        summaryLines.push(...updated.map((file) => `  ${file}`));\n      }\n      if (summaryLines.length > 0) {\n        note(summaryLines.join(\"\\n\"), \"Init summary\");\n      }\n\n      const nextSteps: string[] = [];\n      nextSteps.push(\n        resolved.hasPackageJson\n          ? \"npm run docs:dev\"\n          : `npx ${scriptCommand(\"dev\", writableConfigPath)}`,\n      );\n      nextSteps.push(\n        \"If you want to host docs at the root of a GitHub Pages site, edit basePath/origin in your pagesmith config manually.\",\n      );\n      if (!answers.ai) {\n        nextSteps.push(\"npx pagesmith-docs init --ai  # Optional: install AI integrations\");\n      }\n      note(nextSteps.join(\"\\n\"), \"Next steps\");\n\n      if (interactive) outro(\"Done.\");\n    });\n}\n","import type { Command } from \"cac\";\nimport { withConfigFlag } from \"@pagesmith/core/cli-kit\";\nimport { startDocsMcpServer } from \"../../mcp/server.js\";\n\ntype McpOpts = {\n  config?: string;\n  root?: string;\n  stdio?: boolean;\n};\n\nexport function registerMcpCommand(command: Command): Command {\n  return withConfigFlag(command)\n    .option(\"--root <path>\", \"Project root to resolve config/content paths\")\n    .option(\"--stdio\", \"Use stdio transport (default)\")\n    .action(async (options: McpOpts) => {\n      await startDocsMcpServer({\n        configPath: options.config,\n        rootDir: options.root,\n      });\n    });\n}\n","import type { Command } from \"cac\";\nimport { findPagesmithConfig, withConfigFlag } from \"@pagesmith/core/cli-kit\";\nimport { preview } from \"../../site.js\";\nimport { parseLogLevel, parsePort } from \"../log-level.js\";\n\ntype PreviewOpts = {\n  port?: number | string;\n  config?: string;\n  open?: boolean;\n  outDir?: string;\n  basePath?: string;\n  logLevel?: string;\n};\n\nexport function registerPreviewCommand(command: Command): Command {\n  return withConfigFlag(command)\n    .option(\n      \"-p, --port <number|auto>\",\n      'Server port. Use a number, or \"auto\" to scan upward from 4000 for the first free port (default: server.previewPort, normally 4000).',\n    )\n    .option(\"--open\", \"Open browser on server start\")\n    .option(\"--out-dir <path>\", \"Output directory (overrides config)\")\n    .option(\"--base-path <path>\", \"Base URL path prefix (overrides config)\")\n    .option(\n      \"--log-level <level>\",\n      \"silent|error|warn|info|verbose (default: server.logLevel, normally info)\",\n    )\n    .action(async (options: PreviewOpts) => {\n      const { configPath } = findPagesmithConfig({ explicitPath: options.config });\n      await preview({\n        configPath,\n        port: options.port == null ? undefined : parsePort(options.port),\n        open: options.open,\n        logLevel: options.logLevel ? parseLogLevel(options.logLevel) : undefined,\n        outDir: options.outDir,\n        basePath: options.basePath,\n      });\n    });\n}\n","import type { Command } from \"cac\";\nimport { findPagesmithConfig, withConfigFlag } from \"@pagesmith/core/cli-kit\";\nimport { validateDocs } from \"../../validate.js\";\n\ntype ValidateOpts = {\n  config?: string;\n  contentDir?: string;\n  outDir?: string;\n  basePath?: string;\n  trailingSlash?: boolean;\n  content?: boolean;\n  build?: boolean;\n  checkExternal?: boolean;\n  requireRasterModernFormats?: boolean;\n  requireThemeVariants?: boolean;\n  requireBothTrailingSlashForms?: boolean;\n  internalLinksMustBeMarkdown?: boolean;\n  requireCanonicalInternalLinks?: boolean;\n  requireAltText?: boolean;\n  allowHtmlImgTag?: boolean;\n  themeVariantPairs?: boolean;\n  requiredFile?: string | string[];\n  requiredFiles?: boolean;\n  contentConfig?: string | boolean;\n  full?: boolean;\n  timeoutMs?: number;\n  concurrency?: number;\n  showClean?: boolean;\n};\n\nfunction asArray(input: string | string[] | undefined): string[] | undefined {\n  if (!input) return undefined;\n  return Array.isArray(input) ? input : [input];\n}\n\nexport function registerValidateCommand(command: Command): Command {\n  return withConfigFlag(command)\n    .option(\"--content-dir <path>\", \"Content directory override\")\n    .option(\"--out-dir <path>\", \"Build output directory override\")\n    .option(\"--base-path <path>\", \"Site base path override\")\n    .option(\"--trailing-slash\", \"Force trailing-slash routing mode\")\n    .option(\"--no-trailing-slash\", \"Force flat HTML files routing mode\")\n    .option(\"--content\", \"Run only content validation\")\n    .option(\"--build\", \"Run only build-output validation\")\n    .option(\"--check-external\", \"Fetch external URLs and report non-2xx as warnings\")\n    .option(\n      \"--require-raster-modern-formats\",\n      \"Require webp+avif siblings for <picture> raster fallbacks\",\n    )\n    .option(\"--require-theme-variants\", \"Require both light + dark <picture> sources (default: on)\")\n    .option(\"--no-theme-variants\", \"Opt out of the default theme-variant check\")\n    .option(\"--require-both-trailing-slash-forms\", \"Warn when pages are missing a redirect sibling\")\n    .option(\n      \"--internal-links-must-be-markdown\",\n      \"Fail if a non-image internal link resolves to a non-markdown file\",\n    )\n    .option(\n      \"--require-canonical-internal-links\",\n      \"Require internal page links be authored as ./relative/path.md (default: on under docs preset)\",\n    )\n    .option(\n      \"--no-require-canonical-internal-links\",\n      \"Accept absolute /guide/foo and bare ./foo forms for internal page links\",\n    )\n    .option(\"--no-require-alt-text\", \"Downgrade missing image alt text from error to warning\")\n    .option(\"--allow-html-img-tag\", \"Allow raw <img> tags in markdown (default: disallowed)\")\n    .option(\"--no-theme-variant-pairs\", \"Do not enforce adjacent -light/-dark image pairing\")\n    .option(\"--required-file <name>\", \"Require <name> to exist in the build output (repeatable)\")\n    .option(\"--no-required-files\", \"Skip the default required-output-files check\")\n    .option(\"--content-config <path>\", \"Explicit content.config.{ts,mjs,...} path\")\n    .option(\"--no-content-config\", \"Disable content.config auto-loading and per-file schema checks\")\n    .option(\"--full\", \"Enable every opt-in offline check\")\n    .option(\"--timeout-ms <number>\", \"External fetch timeout (default: 10000)\")\n    .option(\"--concurrency <number>\", \"External fetch concurrency (default: 8)\")\n    .option(\"--show-clean\", \"List files that pass content validation\")\n    .action(async (options: ValidateOpts) => {\n      const { configPath } = findPagesmithConfig({ explicitPath: options.config });\n      const fullPreset = options.full === true;\n\n      const requireRasterModernFormats =\n        options.requireRasterModernFormats === true ? true : fullPreset ? true : undefined;\n      const requireBothTrailingSlashForms =\n        options.requireBothTrailingSlashForms === true ? true : fullPreset ? true : undefined;\n      const internalLinksMustBeMarkdown =\n        options.internalLinksMustBeMarkdown === true ? true : fullPreset ? true : undefined;\n\n      const result = await validateDocs({\n        configPath,\n        contentDir: options.contentDir,\n        outDir: options.outDir,\n        basePath: options.basePath,\n        trailingSlash: options.trailingSlash,\n        skipContent: options.build === true && options.content !== true,\n        skipBuild: options.content === true && options.build !== true,\n        checkExternal: options.checkExternal,\n        requireRasterModernFormats,\n        requireThemeVariants:\n          options.requireThemeVariants === false\n            ? false\n            : options.requireThemeVariants === true\n              ? true\n              : undefined,\n        requireBothTrailingSlashForms,\n        internalLinksMustBeMarkdown,\n        requireCanonicalInternalLinks:\n          options.requireCanonicalInternalLinks === false\n            ? false\n            : options.requireCanonicalInternalLinks === true\n              ? true\n              : undefined,\n        requireAltText: options.requireAltText === false ? false : undefined,\n        forbidHtmlImgTag: options.allowHtmlImgTag === true ? false : undefined,\n        requireThemeVariantPairs: options.themeVariantPairs === false ? false : undefined,\n        requiredOutputFiles: options.requiredFiles === false ? [] : asArray(options.requiredFile),\n        contentConfig:\n          options.contentConfig === false\n            ? false\n            : typeof options.contentConfig === \"string\"\n              ? options.contentConfig\n              : undefined,\n        timeoutMs: options.timeoutMs,\n        concurrency: options.concurrency,\n        showClean: options.showClean,\n      });\n\n      console.info(\n        `\\nSummary: ${result.errors} error(s), ${result.warnings} warning(s) — ${\n          result.passed ? \"PASSED\" : \"FAILED\"\n        }`,\n      );\n      if (!result.passed) process.exit(1);\n    });\n}\n","#!/usr/bin/env node\n\nimport { defineCli, readPackageVersion } from \"@pagesmith/core/cli-kit\";\nimport { registerBuildCommand } from \"./commands/build.js\";\nimport { registerDevCommand } from \"./commands/dev.js\";\nimport { registerInitCommand } from \"./commands/init.js\";\nimport { registerMcpCommand } from \"./commands/mcp.js\";\nimport { registerPreviewCommand } from \"./commands/preview.js\";\nimport { registerValidateCommand } from \"./commands/validate.js\";\n\nconst version = readPackageVersion(import.meta.dirname);\n\nconst cliInstance = defineCli({\n  name: \"pagesmith-docs\",\n  version,\n  description: \"@pagesmith/docs CLI — convention-based documentation site tooling\",\n});\nconst { cli } = cliInstance;\n\ncli.usage(\n  `<command> [options]\n\nInteractive mode is automatic when stdout/stdin are TTYs and neither --yes nor\n--non-interactive is passed. Set CI=1 or PAGESMITH_NON_INTERACTIVE=1 to force\nnon-interactive execution. In non-interactive mode, init fails when --name,\n--origin, or --base-path is missing from both flags and any\npagesmith.config.{ts,mts,js,mjs,json5,json}.\n\nProject defaults: prompt defaults are read from whichever\npagesmith.config.{ts,mts,js,mjs,json5,json} the loader finds first (closest\nmatch in the cwd; --config <path> overrides discovery).`,\n);\n\nregisterInitCommand(cli.command(\"init\", \"Initialize a docs project (interactive)\"), version);\nregisterDevCommand(cli.command(\"dev\", \"Start a docs dev server\"));\nregisterBuildCommand(cli.command(\"build\", \"Build a docs site\"));\nregisterPreviewCommand(cli.command(\"preview\", \"Preview the built docs site\"));\nregisterValidateCommand(\n  cli.command(\"validate\", \"Validate content + build output using pagesmith.config\"),\n);\nregisterMcpCommand(cli.command(\"mcp\", \"Start stdio MCP server for docs tooling\"));\n\nconst exitCode = await cliInstance.run();\nif (exitCode !== 0) process.exit(exitCode);\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,qBAAqB,SAA2B;CAC9D,OAAO,eAAe,OAAO,EAC1B,OAAO,oBAAoB,qCAAqC,EAChE,OAAO,sBAAsB,yCAAyC,EACtE,OAAO,OAAO,YAAuB;EACpC,MAAM,EAAE,eAAe,oBAAoB,EAAE,cAAc,QAAQ,OAAO,CAAC;EAC3E,MAAM,MAAM;GACV;GACA,QAAQ,QAAQ;GAChB,UAAU,QAAQ;EACpB,CAAC;CACH,CAAC;AACL;;;ACpBA,SAAgB,cAAc,OAAyB;CACrD,MAAM,aAAa,MAAM,KAAK,EAAE,YAAY;CAC5C,IAAI,eAAe,UAAU,OAAO;CACpC,IAAI,eAAe,WAAW,eAAe,UAAU,OAAO;CAC9D,IAAI,eAAe,UAAU,eAAe,aAAa,eAAe,YAAY,OAAO;CAC3F,IAAI,eAAe,UAAU,eAAe,OAAO,OAAO;CAC1D,IAAI,eAAe,aAAa,eAAe,SAAS,OAAO;CAC/D,MAAM,IAAI,MACR,wEAAwE,MAAM,GAChF;AACF;;;;;AAMA,SAAgB,UAAU,OAAyC;CACjE,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,YAAY,MAAM,QAC9D,OAAO;CAET,MAAM,OAAO,OAAO,UAAU,WA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oB,CAAC;EAC3B,IAAI,UAAU;EAEd,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAChD,IAAI,CAAC,QAAQ,OAAO;GAClB,QAAQ,QAAQ;GAChB,QAAQ,KAAK,wBAAwB,MAAM;GAC3C,UAAU;EACZ;EAGF,IAAI,CAAC,SAAS,OAAO;EAErB,IAAI,UAAU;EACd,cAAc,SAAS,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE,GAAG;EAC1D,OAAO;CACT,QAAQ;EACN,OAAO,CAAC;CACV;AACF;AAEA,SAAS,eAAe,UAAkB,SAA0B;CAClE,IAAI,WAAW,QAAQ,GAAG,OAAO;CACjC,cAAc,UAAU,OAAO;CAC/B,OAAO;AACT;AAEA,MAAM,gBAAmF;CACvF;EACE,KAAK;EACL,UAAU,MACR;GACE;GACA,UAAU,EAAE;GACZ,uBAAuB,EAAE;GACzB,gBAAgB,EAAE,MAAM;GACxB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,EAAE,KAAK,IAAI;CACf;CACA;EACE,KAAK;EACL,eACE;GACE;GACA;GACA;GACA;GACA;GACA;EACF,EAAE,KAAK,IAAI;CACf;CACA;EACE,KAAK;EACL,eACE;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,EAAE,KAAK,IAAI;CACf;CACA;EACE,KAAK;EACL,eACE;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,EAAE,KAAK,IAAI;CACf;CACA;EACE,KAAK;EACL,eACE;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,EAAE,KAAK,IAAI;CACf;CACA;EACE,KAAK;EACL,eACE;GACE;GACA;GACA;GACA;GACA;GACA;EACF,EAAE,KAAK,IAAI;CACf;CACA;EACE,KAAK;EACL,eACE;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,EAA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