designsource 0.10.0 → 0.11.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 (3) hide show
  1. package/README.md +2 -1
  2. package/dist/index.js +402 -160
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -7,9 +7,10 @@
7
7
  The command line for a [DS source](https://designsource.app) design system. Node 20 or newer, zero runtime dependencies; also installed as **`dss`**.
8
8
 
9
9
  - **[`add`](https://designsource.app/docs/cli/add)** — add the UI kit to the React app you already have: your theme in its global stylesheet, the 61 components and the libraries they import, the Tailwind and shadcn setup when the app lacks it, and a `/design-system` section showing them. Run it again to pull updates.
10
- - **`add --screen`** — pull a screen you made in the workbench into your app as code: `npx designsource add --screen customers` (or `--screen all`) writes the screen, its sample data and the parts it uses, with the kit components it needs. `add --screen shell` adds a sidebar app shell that links them. [More](https://designsource.app/docs/cli/screens).
10
+ - **`add --screen`** — pull a screen you made in the workbench into your app as code: `npx designsource add --screen customers` (or `--screen all`) writes the screen, its sample data and the parts it uses, with the kit components it needs. `add --screen shell` adds a sidebar app shell that links them, and `add --screen site` a menu and footer that list the marketing pages in your app. [More](https://designsource.app/docs/cli/screens).
11
11
  - **[`connect`](https://designsource.app/docs/cli/connect)** — connect your coding apps (Claude Code, Cursor, VS Code, Codex, Gemini CLI) to the design system: the project token saved once, privately, on this computer, and each app's MCP settings written in the project with no token in them.
12
12
  - **[`login`](https://designsource.app/docs/cli/login-and-logout)** / **`logout`** — sign this computer in to your account for coding agents, so your agent can create a design system for the app it is working on and add its UI kit.
13
+ - **Pages** — the marketing pages you made (home, pricing, waitlist) come with `add --screen` too, and `create` puts them on their own routes with the home page at `/`. The CLI always asks the server for them.
13
14
  - **[`create`](https://designsource.app/docs/cli/create-and-integrate)** — a new Next.js project from it: tokens, every component, a front page, the design system under `/design-system` and your screens on `/app/<name>` in a sidebar shell (`--no-screens` leaves them out).
14
15
  - **[`integrate`](https://designsource.app/docs/cli/create-and-integrate)** — a `design-system/` folder for Vue, Svelte, Angular or plain CSS: your tokens as CSS variables, a prompt for your coding agent, the component kit as reference.
15
16
  - **[`mcp`](https://designsource.app/docs/cli/mcp)** — serve the design system to your coding agent over MCP: tokens, component source, blocks, your mockup page, an integration guide, and tools that add the UI kit (and your screens, with `screens`), list and read screens (`list_screens`, `get_screen_source`), create a design system, or, signed in with `login`, make a screen (`generate_screen`, which spends credits or your key and writes no files). `connect` and `login` write its config for you.
package/dist/index.js CHANGED
@@ -993,7 +993,7 @@ function planToml(path, text, projectId) {
993
993
 
994
994
  // src/add/screen-rules.ts
995
995
  var SCREEN_SLUG = /^[a-z][a-z0-9-]{0,39}$/;
996
- var RESERVED_SCREEN_SLUGS = ["all", "shell", "app-shell", "parts"];
996
+ var RESERVED_SCREEN_SLUGS = ["all", "shell", "app-shell", "parts", "app", "design-system", "api", "site"];
997
997
  var SCREEN_COMPONENT = /^[A-Z][A-Za-z0-9]*Screen$/;
998
998
  var SCREEN_PART_FILE = /^[a-z][a-z0-9-]*\.tsx?$/;
999
999
  var SCREENS_QUERY_MAX = 50;
@@ -1038,7 +1038,7 @@ ${TOKEN_LINE}
1038
1038
  ${API_LINE}
1039
1039
  --force overwrite files the bundle writes when design-system/ already exists
1040
1040
  `;
1041
- var ADD_USAGE = `designsource add [names\u2026] [--yes] [--all] [--force] [--skip-install] [--no-blocks] [--screen <name>|all|shell] [--token <project token>] [--api <origin>]
1041
+ var ADD_USAGE = `designsource add [names\u2026] [--yes] [--all] [--force] [--skip-install] [--no-blocks] [--screen <name>|all|shell|site] [--token <project token>] [--api <origin>]
1042
1042
 
1043
1043
  Adds your design system's UI kit to the React app in this folder: the theme in its global stylesheet, the
1044
1044
  components and the libraries they import. Sets up Tailwind and the shadcn config when the app has none.
@@ -1051,8 +1051,9 @@ your components, blocks and sample pages.
1051
1051
  --force replace component files add did not write, and edited ones
1052
1052
  --skip-install write the files, then print the install command instead of running it
1053
1053
  --no-blocks the /design-system section without its blocks and their libraries (blocks already there stay)
1054
- --screen screens from DS source, by file name (repeatable, or comma-separated); all for every one; shell for
1055
- a sidebar app shell listing the screens in the app
1054
+ --screen screens and pages from DS source, by file name (repeatable, or comma-separated); all for every one;
1055
+ shell for a sidebar app shell listing the screens in the app; site for the menu and footer around
1056
+ the pages in the app
1056
1057
  --token the project token (workbench \u2192 Project settings); or DS_SYNC_TOKEN
1057
1058
  --api API origin (default ${DEFAULT_API_ORIGIN})
1058
1059
  `;
@@ -1177,8 +1178,8 @@ var SCREEN_NAME_MESSAGE = "--screen takes screen names from DS source (letters,
1177
1178
  function screensIn(values, usage) {
1178
1179
  const words = values.flatMap((v) => v.split(",").map((w) => w.trim()));
1179
1180
  if (words.some((n) => n === "")) throw new ArgsError(SCREEN_NAME_MESSAGE, usage);
1180
- const shell = words.includes("shell") ? { shell: true } : {};
1181
- const names = words.filter((n) => n !== "shell");
1181
+ const shell = { ...words.includes("shell") ? { shell: true } : {}, ...words.includes("site") ? { site: true } : {} };
1182
+ const names = words.filter((n) => n !== "shell" && n !== "site");
1182
1183
  if (names.includes("all")) return { screens: "all", ...shell };
1183
1184
  for (const n of names) {
1184
1185
  if (!SCREEN_SLUG.test(n) || RESERVED_SCREEN_SLUGS.includes(n)) throw new ArgsError(SCREEN_NAME_MESSAGE, usage);
@@ -1502,6 +1503,11 @@ import { join as join4 } from "node:path";
1502
1503
 
1503
1504
  // src/add/screen-gen.ts
1504
1505
  var SCREEN_KINDS = ["list", "detail", "settings", "form", "dashboard"];
1506
+ var PAGE_KINDS = ["home", "pricing", "waitlist"];
1507
+ function isPageKind(kind) {
1508
+ return PAGE_KINDS.includes(kind);
1509
+ }
1510
+ var isAppScreen = (s) => !isPageKind(s.kind);
1505
1511
  var SCREEN_KIND_ICON_NAMES = {
1506
1512
  list: "ListDetailsIcon",
1507
1513
  detail: "UserIcon",
@@ -1522,7 +1528,7 @@ function checkShellScreens(screens) {
1522
1528
  if (RESERVED_SCREEN_SLUGS.includes(s.slug)) throw new Error("Reserved screen slug");
1523
1529
  if (seen.has(s.slug)) throw new Error("Duplicate screen slug");
1524
1530
  seen.add(s.slug);
1525
- if (!SCREEN_KINDS.includes(s.kind)) throw new Error("Unknown screen kind");
1531
+ if (typeof s.kind !== "string" || !SCREEN_KINDS.includes(s.kind) && !isPageKind(s.kind)) throw new Error("Unknown screen kind");
1526
1532
  if (typeof s.title !== "string") throw new Error("Invalid screen title");
1527
1533
  }
1528
1534
  }
@@ -1531,7 +1537,7 @@ function assembleAppShell(input) {
1531
1537
  if (typeof input.name !== "string") throw new Error("Invalid app name");
1532
1538
  if (input.hrefFor !== "app" && input.hrefFor !== "root") throw new Error("Invalid hrefFor");
1533
1539
  const prefix = input.hrefFor === "app" ? "/app/" : "/";
1534
- const links = input.screens.map((s) => ({ href: `${prefix}${s.slug}`, title: s.title, kind: s.kind }));
1540
+ const links = input.screens.filter(isAppScreen).map((s) => ({ href: `${prefix}${s.slug}`, title: s.title, kind: s.kind }));
1535
1541
  const icons = [...new Set(SCREEN_KINDS.map((k) => SCREEN_KIND_ICON_NAMES[k]))].sort();
1536
1542
  const kindIcons = SCREEN_KINDS.map((k) => ` ${k}: ${SCREEN_KIND_ICON_NAMES[k]},`);
1537
1543
  return [
@@ -1626,14 +1632,19 @@ function assembleAppShell(input) {
1626
1632
  var DEFAULT_SCREENS_IMPORT = "@/components/screens";
1627
1633
  var SCREENS_IMPORT = /^[A-Za-z0-9@~#_.-]+(?:\/[A-Za-z0-9@~#_.-]+)*$/;
1628
1634
  var HEAD = [
1629
- `export type SectionScreenKind = ${SCREEN_KINDS.map((k) => `'${k}'`).join(" | ")}`,
1635
+ `export type SectionScreenKind = ${[...SCREEN_KINDS, ...PAGE_KINDS].map((k) => `'${k}'`).join(" | ")}`,
1630
1636
  "export type SectionScreenEntry = { slug: string; title: string; kind: SectionScreenKind }"
1631
1637
  ];
1632
1638
  function assembleScreenRegistry(input) {
1633
1639
  checkShellScreens(input.screens);
1634
1640
  const screensImport = input.screensImport ?? DEFAULT_SCREENS_IMPORT;
1635
1641
  if (typeof screensImport !== "string" || !SCREENS_IMPORT.test(screensImport)) throw new Error("Invalid screensImport");
1642
+ if (typeof input.name !== "string") throw new Error("Invalid site name");
1643
+ if (!Number.isInteger(input.year)) throw new Error("Invalid year");
1644
+ if (input.action !== void 0 && typeof input.action !== "string") throw new Error("Invalid action label");
1636
1645
  const entries = input.screens.map((s) => ({ slug: s.slug, title: s.title, kind: s.kind }));
1646
+ const pages = entries.flatMap((s) => isPageKind(s.kind) ? [{ slug: s.slug, title: s.title, kind: s.kind }] : []);
1647
+ const site = siteFrameProps({ name: input.name, pages, year: input.year, fallbackActionLabel: input.action });
1637
1648
  if (entries.length === 0) {
1638
1649
  return [
1639
1650
  ...HEAD,
@@ -1651,8 +1662,36 @@ function assembleScreenRegistry(input) {
1651
1662
  const views = entries.map(
1652
1663
  (s) => ` ${jsonLiteral(s.slug)}: lazy(() => import(${jsonLiteral(`${screensImport}/${s.slug}`)}).then((m) => ({ default: m.${screenComponentName(s.slug)} }))),`
1653
1664
  );
1665
+ if (pages.length === 0) {
1666
+ return [
1667
+ "import { lazy, Suspense, type ComponentType } from 'react'",
1668
+ "",
1669
+ ...HEAD,
1670
+ "",
1671
+ `export const SECTION_SCREENS: SectionScreenEntry[] = ${jsonLiteral(entries, 2)}`,
1672
+ "",
1673
+ "const VIEWS: Record<string, ComponentType> = {",
1674
+ ...views,
1675
+ "}",
1676
+ "",
1677
+ "export function SectionScreen({ slug }: { slug: string }) {",
1678
+ " const View = Object.prototype.hasOwnProperty.call(VIEWS, slug) ? VIEWS[slug] : undefined",
1679
+ " if (!View) return null",
1680
+ " return (",
1681
+ " <Suspense fallback={null}>",
1682
+ " <View />",
1683
+ " </Suspense>",
1684
+ " )",
1685
+ "}",
1686
+ "",
1687
+ "SectionScreen.displayName = 'SectionScreen'",
1688
+ ""
1689
+ ].join("\n");
1690
+ }
1654
1691
  return [
1655
- "import { lazy, Suspense, type ComponentType } from 'react'",
1692
+ "import { lazy, Suspense, type ComponentProps, type ComponentType } from 'react'",
1693
+ `import { SiteFrame, SiteHeader, SiteFooter } from '${screensImport}/parts/site-frame'`,
1694
+ `import { SiteLinksProvider } from '${screensImport}/parts/site-links'`,
1656
1695
  "",
1657
1696
  ...HEAD,
1658
1697
  "",
@@ -1662,12 +1701,33 @@ function assembleScreenRegistry(input) {
1662
1701
  ...views,
1663
1702
  "}",
1664
1703
  "",
1704
+ "/** The marketing pages: drawn inside the site menu and footer, their links inert, since the section is a showcase. */",
1705
+ `const PAGES: ReadonlySet<string> = new Set(${jsonLiteral(pages.map((p) => p.slug))})`,
1706
+ "",
1707
+ "type SiteProps = {",
1708
+ " hrefs: ComponentProps<typeof SiteLinksProvider>['value']['hrefs']",
1709
+ " header: ComponentProps<typeof SiteHeader>",
1710
+ " footer: ComponentProps<typeof SiteFooter>",
1711
+ "}",
1712
+ "",
1713
+ `const SITE: SiteProps = ${jsonLiteral(site, 2)}`,
1714
+ "",
1665
1715
  "export function SectionScreen({ slug }: { slug: string }) {",
1666
1716
  " const View = Object.prototype.hasOwnProperty.call(VIEWS, slug) ? VIEWS[slug] : undefined",
1667
1717
  " if (!View) return null",
1668
1718
  " return (",
1669
1719
  " <Suspense fallback={null}>",
1670
- " <View />",
1720
+ " {PAGES.has(slug) ? (",
1721
+ " <SiteLinksProvider value={{ hrefs: SITE.hrefs, inert: true }}>",
1722
+ " <SiteFrame>",
1723
+ " <SiteHeader {...SITE.header} />",
1724
+ " <View />",
1725
+ " <SiteFooter {...SITE.footer} />",
1726
+ " </SiteFrame>",
1727
+ " </SiteLinksProvider>",
1728
+ " ) : (",
1729
+ " <View />",
1730
+ " )}",
1671
1731
  " </Suspense>",
1672
1732
  " )",
1673
1733
  "}",
@@ -1676,6 +1736,74 @@ function assembleScreenRegistry(input) {
1676
1736
  ""
1677
1737
  ].join("\n");
1678
1738
  }
1739
+ function checkSitePages(pages) {
1740
+ const kinds = /* @__PURE__ */ new Set();
1741
+ for (const p of pages) {
1742
+ if (typeof p.slug !== "string" || !SCREEN_SLUG.test(p.slug)) throw new Error("Invalid page slug");
1743
+ if (RESERVED_SCREEN_SLUGS.includes(p.slug)) throw new Error("Reserved page slug");
1744
+ if (typeof p.kind !== "string" || !isPageKind(p.kind)) throw new Error("Unknown page kind");
1745
+ if (kinds.has(p.kind)) throw new Error("Duplicate page kind");
1746
+ kinds.add(p.kind);
1747
+ if (typeof p.title !== "string") throw new Error("Invalid page title");
1748
+ }
1749
+ }
1750
+ var inKindOrder = (pages) => PAGE_KINDS.flatMap((k) => pages.filter((p) => p.kind === k));
1751
+ function siteFrameProps(input) {
1752
+ checkSitePages(input.pages);
1753
+ const ordered = inKindOrder(input.pages);
1754
+ const hrefs = {};
1755
+ for (const p of ordered) hrefs[p.kind] = p.kind === "home" ? "/" : `/${p.slug}`;
1756
+ const action = ordered.some((p) => p.kind === "waitlist") ? { label: "Join the waitlist", variant: "default", to: "waitlist" } : { label: input.fallbackActionLabel ?? "Get started", variant: "default" };
1757
+ return {
1758
+ hrefs,
1759
+ header: {
1760
+ name: input.name,
1761
+ links: ordered.filter((p) => p.kind !== "home" && p.kind !== "waitlist").map((p) => ({ label: p.title, to: p.kind })),
1762
+ action
1763
+ },
1764
+ footer: { name: input.name, links: ordered.map((p) => ({ label: p.title, to: p.kind })), year: input.year }
1765
+ };
1766
+ }
1767
+ function assembleSiteShell(input) {
1768
+ checkSitePages(input.pages);
1769
+ if (typeof input.name !== "string") throw new Error("Invalid site name");
1770
+ if (!Number.isInteger(input.year)) throw new Error("Invalid year");
1771
+ if (input.fallbackActionLabel !== void 0 && typeof input.fallbackActionLabel !== "string") throw new Error("Invalid action label");
1772
+ const { hrefs, header, footer } = siteFrameProps({
1773
+ name: input.name,
1774
+ pages: input.pages,
1775
+ year: input.year,
1776
+ fallbackActionLabel: input.fallbackActionLabel
1777
+ });
1778
+ return [
1779
+ "'use client'",
1780
+ "",
1781
+ "import type { ComponentProps } from 'react'",
1782
+ "import { SiteFrame, SiteHeader, SiteFooter } from '@/components/screens/parts/site-frame'",
1783
+ "import { SiteLinksProvider } from '@/components/screens/parts/site-links'",
1784
+ "",
1785
+ `const hrefs: ComponentProps<typeof SiteLinksProvider>['value']['hrefs'] = ${jsonLiteral(hrefs, 2)}`,
1786
+ "",
1787
+ `const header: ComponentProps<typeof SiteHeader> = ${jsonLiteral(header, 2)}`,
1788
+ "",
1789
+ `const footer: ComponentProps<typeof SiteFooter> = ${jsonLiteral(footer, 2)}`,
1790
+ "",
1791
+ "export function SiteShell({ children }: { children: React.ReactNode }) {",
1792
+ " return (",
1793
+ " <SiteLinksProvider value={{ hrefs }}>",
1794
+ " <SiteFrame>",
1795
+ " <SiteHeader {...header} />",
1796
+ " {children}",
1797
+ " <SiteFooter {...footer} />",
1798
+ " </SiteFrame>",
1799
+ " </SiteLinksProvider>",
1800
+ " )",
1801
+ "}",
1802
+ "",
1803
+ "SiteShell.displayName = 'SiteShell'",
1804
+ ""
1805
+ ].join("\n");
1806
+ }
1679
1807
 
1680
1808
  // src/add/section.ts
1681
1809
  var SECTION_NEEDS_FULL_KIT = "The /design-system section comes with the full kit: run designsource add --all.";
@@ -1697,8 +1825,12 @@ function sectionReadsScreens(root, t) {
1697
1825
  }
1698
1826
  }
1699
1827
  var registryPath = (componentsDir) => join22(componentsDir, "design-system/section-screens.tsx");
1700
- function registryFile(componentsDir, t, screens) {
1701
- return stamped(registryPath(componentsDir), REGISTRY_STAMP, rewriteForApp(assembleScreenRegistry({ screens }), t));
1828
+ function registrySite(manifest, year = (/* @__PURE__ */ new Date()).getUTCFullYear()) {
1829
+ const action = manifest.screenIndex?.find((e) => e.kind === "home")?.action;
1830
+ return { name: manifest.name, year, ...typeof action === "string" ? { action } : {} };
1831
+ }
1832
+ function registryFile(componentsDir, t, screens, site) {
1833
+ return stamped(registryPath(componentsDir), REGISTRY_STAMP, rewriteForApp(assembleScreenRegistry({ screens, ...site }), t));
1702
1834
  }
1703
1835
  function shownBlockGroups(groups, blocks, keptBlockIds = []) {
1704
1836
  if (blocks === "write") return groups;
@@ -1756,7 +1888,7 @@ function planSectionFiles(input) {
1756
1888
  }
1757
1889
  if (blocks === "skip") files.push(stamped(ds("block-view.tsx"), "section:block-view", NO_BLOCKS_VIEW));
1758
1890
  const screens = sectionKnowsScreens(manifest);
1759
- if (screens && input.screens !== null) files.push(registryFile(componentsDir, t, input.screens));
1891
+ if (screens && input.screens !== null) files.push(registryFile(componentsDir, t, input.screens, registrySite(manifest)));
1760
1892
  else if (screens && !input.registryOnDisk) {
1761
1893
  const fallback = section.files.find((f) => f.key === REGISTRY_KEY);
1762
1894
  files.push(stamped(registryPath(componentsDir), REGISTRY_STAMP, rewriteForApp(fallback.contents, t)));
@@ -2358,89 +2490,6 @@ async function postNdjson(opts, fetchImpl = fetch) {
2358
2490
  }
2359
2491
  }
2360
2492
 
2361
- // src/add/kit-manifest.ts
2362
- var malformed = () => new CliError("Unexpected response from the API \u2014 not a kit manifest.");
2363
- var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
2364
- var isStrings = (v) => Array.isArray(v) && v.every((s) => typeof s === "string");
2365
- var isStringMap = (v) => isRecord(v) && Object.values(v).every((s) => typeof s === "string");
2366
- var isSectionFile = (f) => isRecord(f) && typeof f.key === "string" && typeof f.contents === "string" && isStrings(f.kitImports) && isStrings(f.packages) && typeof f.block === "boolean";
2367
- var isBlockGroup = (g) => isRecord(g) && typeof g.family === "string" && typeof g.label === "string" && Array.isArray(g.blocks) && g.blocks.every((b) => isRecord(b) && typeof b.id === "string" && typeof b.title === "string");
2368
- function validateSection(s) {
2369
- if (!isRecord(s) || !Array.isArray(s.files) || !s.files.every(isSectionFile)) throw malformed();
2370
- if (typeof s.themeCss !== "string" || !Array.isArray(s.blockGroups) || !s.blockGroups.every(isBlockGroup)) throw malformed();
2371
- if (!isStringMap(s.packages) || !isStringMap(s.blockPackages)) throw malformed();
2372
- return { files: s.files, themeCss: s.themeCss, blockGroups: s.blockGroups, packages: s.packages, blockPackages: s.blockPackages, mockupSpec: s.mockupSpec ?? null };
2373
- }
2374
- var isScreen = (s) => {
2375
- if (!isRecord(s) || typeof s.slug !== "string" || !SCREEN_SLUG.test(s.slug) || typeof s.title !== "string") return false;
2376
- if (typeof s.component !== "string" || !SCREEN_COMPONENT.test(s.component) || !isStrings(s.parts)) return false;
2377
- if (!Array.isArray(s.files) || s.files.length !== 2) return false;
2378
- if (!s.files.every((f) => isRecord(f) && typeof f.file === "string" && typeof f.contents === "string")) return false;
2379
- return s.files[0].file === `${s.slug}.tsx` && s.files[1].file === `${s.slug}.data.ts`;
2380
- };
2381
- var isScreenPart = (p) => isRecord(p) && typeof p.name === "string" && typeof p.file === "string" && SCREEN_PART_FILE.test(p.file) && p.file.replace(/\.tsx?$/, "") === p.name && typeof p.contents === "string" && isStrings(p.kitImports) && isStrings(p.partImports) && isStrings(p.packages);
2382
- var isScreenEntry = (e) => isRecord(e) && typeof e.slug === "string" && SCREEN_SLUG.test(e.slug) && !RESERVED_SCREEN_SLUGS.includes(e.slug) && typeof e.title === "string" && typeof e.available === "boolean" && (e.kind === void 0 || typeof e.kind === "string" && SCREEN_KINDS.includes(e.kind));
2383
- function validateKitManifest(json) {
2384
- if (!isRecord(json)) throw malformed();
2385
- if (typeof json.version !== "number") throw malformed();
2386
- if (json.version !== 1) throw new CliError(UPDATE_MESSAGE);
2387
- if (json.kind !== "kit" || typeof json.name !== "string" || typeof json.utils !== "string") throw malformed();
2388
- const { theme } = json;
2389
- if (!isRecord(theme) || typeof theme.css !== "string" || !isStrings(theme.fontImports)) throw malformed();
2390
- if (!Array.isArray(json.components)) throw malformed();
2391
- for (const c of json.components) {
2392
- if (!isRecord(c)) throw malformed();
2393
- if (typeof c.name !== "string" || typeof c.file !== "string" || typeof c.contents !== "string") throw malformed();
2394
- if (!isStrings(c.kitImports) || !isStrings(c.packages)) throw malformed();
2395
- }
2396
- if (!isStrings(json.utilsPackages)) throw malformed();
2397
- if (!isStringMap(json.packages) || !isStringMap(json.devPackages)) throw malformed();
2398
- const section = json.section === void 0 ? void 0 : validateSection(json.section);
2399
- const { screens, screenParts, screenIndex } = json;
2400
- if (screens !== void 0 && !(Array.isArray(screens) && screens.every(isScreen))) throw malformed();
2401
- if (screenParts !== void 0 && !(Array.isArray(screenParts) && screenParts.every(isScreenPart))) throw malformed();
2402
- if (screenIndex !== void 0 && !(Array.isArray(screenIndex) && screenIndex.every(isScreenEntry))) throw malformed();
2403
- if (screens !== void 0) {
2404
- const slugs = /* @__PURE__ */ new Set();
2405
- for (const s of screens) {
2406
- if (RESERVED_SCREEN_SLUGS.includes(s.slug) || slugs.has(s.slug)) throw malformed();
2407
- slugs.add(s.slug);
2408
- }
2409
- }
2410
- if (screenParts !== void 0) {
2411
- const names = /* @__PURE__ */ new Set();
2412
- for (const p of screenParts) {
2413
- if (names.has(p.name)) throw malformed();
2414
- names.add(p.name);
2415
- }
2416
- for (const s of screens ?? []) if (s.parts.some((n) => !names.has(n))) throw malformed();
2417
- } else if ((screens ?? []).some((s) => s.parts.length > 0)) throw malformed();
2418
- return {
2419
- version: 1,
2420
- kind: "kit",
2421
- name: json.name,
2422
- theme: { css: theme.css, fontImports: theme.fontImports },
2423
- components: json.components,
2424
- utils: json.utils,
2425
- utilsPackages: json.utilsPackages,
2426
- packages: json.packages,
2427
- devPackages: json.devPackages,
2428
- ...section ? { section } : {},
2429
- ...screens !== void 0 ? { screens } : {},
2430
- ...screenParts !== void 0 ? { screenParts } : {},
2431
- ...screenIndex !== void 0 ? { screenIndex: screenIndex.map((e) => ({ slug: e.slug, title: e.title, available: e.available, kind: e.kind ?? "list" })) } : {}
2432
- };
2433
- }
2434
-
2435
- // src/add/fetch-kit.ts
2436
- async function fetchKit(opts, fetchImpl = fetch) {
2437
- const { api, token, screens, messages } = opts;
2438
- const asAll = screens === "all" || Array.isArray(screens) && (screens.includes("all") || new Set(screens).size > SCREENS_QUERY_MAX);
2439
- const query = screens === void 0 || Array.isArray(screens) && screens.length === 0 ? "" : `?screens=${encodeURIComponent(asAll ? "all" : screens.join(","))}`;
2440
- const path = `${opts.path ?? "/api/kit"}${query}`;
2441
- return validateKitManifest(await getJson({ api, token, path, ...messages ? { messages } : {} }, fetchImpl));
2442
- }
2443
-
2444
2493
  // src/connect/open-browser.ts
2445
2494
  import { spawn as spawn2 } from "node:child_process";
2446
2495
  var launchDetached = (cmd, args) => new Promise((resolve8) => {
@@ -2498,8 +2547,8 @@ function clientName(hostname2) {
2498
2547
  const host = hostname2.replace(/[^A-Za-z0-9 '._-]/g, "-") || "this computer";
2499
2548
  return `designsource on ${host}`.slice(0, CLIENT_NAME_MAX).trimEnd();
2500
2549
  }
2501
- var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2502
- var errorCode = (body) => isRecord2(body) && typeof body.error === "string" ? body.error : null;
2550
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2551
+ var errorCode = (body) => isRecord(body) && typeof body.error === "string" ? body.error : null;
2503
2552
  function seconds(value, fallback, min, max) {
2504
2553
  const ms = typeof value === "number" && Number.isFinite(value) ? value * 1e3 : fallback;
2505
2554
  return Math.min(max, Math.max(min, ms));
@@ -2511,7 +2560,7 @@ async function deviceLogin(opts) {
2511
2560
  if (code2.status === 429) throw new CliError("Too many sign-in attempts from this network. Wait a while and run npx designsource login again.");
2512
2561
  if (code2.status !== 200) throw new CliError(`${api} answered ${code2.status}.`);
2513
2562
  const body = code2.body;
2514
- if (!isRecord2(body) || typeof body.deviceCode !== "string" || !DEVICE_CODE.test(body.deviceCode) || typeof body.userCode !== "string" || !USER_CODE.test(body.userCode)) {
2563
+ if (!isRecord(body) || typeof body.deviceCode !== "string" || !DEVICE_CODE.test(body.deviceCode) || typeof body.userCode !== "string" || !USER_CODE.test(body.userCode)) {
2515
2564
  throw new CliError(UNEXPECTED);
2516
2565
  }
2517
2566
  const deviceCode = body.deviceCode;
@@ -2540,14 +2589,97 @@ async function deviceLogin(opts) {
2540
2589
  }
2541
2590
  }
2542
2591
  function accepted(body) {
2543
- if (!isRecord2(body) || typeof body.accessToken !== "string" || !ACCOUNT_TOKEN.test(body.accessToken)) throw new CliError("Unexpected account token from the API.");
2592
+ if (!isRecord(body) || typeof body.accessToken !== "string" || !ACCOUNT_TOKEN.test(body.accessToken)) throw new CliError("Unexpected account token from the API.");
2544
2593
  const account = body.account;
2545
- if (!isRecord2(account) || typeof account.email !== "string") throw new CliError(UNEXPECTED);
2594
+ if (!isRecord(account) || typeof account.email !== "string") throw new CliError(UNEXPECTED);
2546
2595
  const email = printable(account.email).slice(0, EMAIL_MAX);
2547
2596
  if (email === "") throw new CliError(UNEXPECTED);
2548
2597
  return { token: body.accessToken, email };
2549
2598
  }
2550
2599
 
2600
+ // src/add/kit-manifest.ts
2601
+ var malformed = () => new CliError("Unexpected response from the API \u2014 not a kit manifest.");
2602
+ var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
2603
+ var isStrings = (v) => Array.isArray(v) && v.every((s) => typeof s === "string");
2604
+ var isStringMap = (v) => isRecord2(v) && Object.values(v).every((s) => typeof s === "string");
2605
+ var isSectionFile = (f) => isRecord2(f) && typeof f.key === "string" && typeof f.contents === "string" && isStrings(f.kitImports) && isStrings(f.packages) && typeof f.block === "boolean";
2606
+ var isBlockGroup = (g) => isRecord2(g) && typeof g.family === "string" && typeof g.label === "string" && Array.isArray(g.blocks) && g.blocks.every((b) => isRecord2(b) && typeof b.id === "string" && typeof b.title === "string");
2607
+ function validateSection(s) {
2608
+ if (!isRecord2(s) || !Array.isArray(s.files) || !s.files.every(isSectionFile)) throw malformed();
2609
+ if (typeof s.themeCss !== "string" || !Array.isArray(s.blockGroups) || !s.blockGroups.every(isBlockGroup)) throw malformed();
2610
+ if (!isStringMap(s.packages) || !isStringMap(s.blockPackages)) throw malformed();
2611
+ return { files: s.files, themeCss: s.themeCss, blockGroups: s.blockGroups, packages: s.packages, blockPackages: s.blockPackages, mockupSpec: s.mockupSpec ?? null };
2612
+ }
2613
+ var isScreen = (s) => {
2614
+ if (!isRecord2(s) || typeof s.slug !== "string" || !SCREEN_SLUG.test(s.slug) || typeof s.title !== "string") return false;
2615
+ if (typeof s.component !== "string" || !SCREEN_COMPONENT.test(s.component) || !isStrings(s.parts)) return false;
2616
+ if (!Array.isArray(s.files) || s.files.length !== 2) return false;
2617
+ if (!s.files.every((f) => isRecord2(f) && typeof f.file === "string" && typeof f.contents === "string")) return false;
2618
+ return s.files[0].file === `${s.slug}.tsx` && s.files[1].file === `${s.slug}.data.ts`;
2619
+ };
2620
+ var isScreenPart = (p) => isRecord2(p) && typeof p.name === "string" && typeof p.file === "string" && SCREEN_PART_FILE.test(p.file) && p.file.replace(/\.tsx?$/, "") === p.name && typeof p.contents === "string" && isStrings(p.kitImports) && isStrings(p.partImports) && isStrings(p.packages);
2621
+ var isScreenEntry = (e) => isRecord2(e) && typeof e.slug === "string" && SCREEN_SLUG.test(e.slug) && !RESERVED_SCREEN_SLUGS.includes(e.slug) && typeof e.title === "string" && typeof e.available === "boolean" && (e.kind === void 0 || typeof e.kind === "string" && (SCREEN_KINDS.includes(e.kind) || isPageKind(e.kind))) && (e.action === void 0 || typeof e.action === "string" && e.action.length <= 60 && printable(e.action) === e.action);
2622
+ function validateKitManifest(json) {
2623
+ if (!isRecord2(json)) throw malformed();
2624
+ if (typeof json.version !== "number") throw malformed();
2625
+ if (json.version !== 1) throw new CliError(UPDATE_MESSAGE);
2626
+ if (json.kind !== "kit" || typeof json.name !== "string" || typeof json.utils !== "string") throw malformed();
2627
+ const { theme } = json;
2628
+ if (!isRecord2(theme) || typeof theme.css !== "string" || !isStrings(theme.fontImports)) throw malformed();
2629
+ if (!Array.isArray(json.components)) throw malformed();
2630
+ for (const c of json.components) {
2631
+ if (!isRecord2(c)) throw malformed();
2632
+ if (typeof c.name !== "string" || typeof c.file !== "string" || typeof c.contents !== "string") throw malformed();
2633
+ if (!isStrings(c.kitImports) || !isStrings(c.packages)) throw malformed();
2634
+ }
2635
+ if (!isStrings(json.utilsPackages)) throw malformed();
2636
+ if (!isStringMap(json.packages) || !isStringMap(json.devPackages)) throw malformed();
2637
+ const section = json.section === void 0 ? void 0 : validateSection(json.section);
2638
+ const { screens, screenParts, screenIndex } = json;
2639
+ if (screens !== void 0 && !(Array.isArray(screens) && screens.every(isScreen))) throw malformed();
2640
+ if (screenParts !== void 0 && !(Array.isArray(screenParts) && screenParts.every(isScreenPart))) throw malformed();
2641
+ if (screenIndex !== void 0 && !(Array.isArray(screenIndex) && screenIndex.every(isScreenEntry))) throw malformed();
2642
+ if (screens !== void 0) {
2643
+ const slugs = /* @__PURE__ */ new Set();
2644
+ for (const s of screens) {
2645
+ if (RESERVED_SCREEN_SLUGS.includes(s.slug) || slugs.has(s.slug)) throw malformed();
2646
+ slugs.add(s.slug);
2647
+ }
2648
+ }
2649
+ if (screenParts !== void 0) {
2650
+ const names = /* @__PURE__ */ new Set();
2651
+ for (const p of screenParts) {
2652
+ if (names.has(p.name)) throw malformed();
2653
+ names.add(p.name);
2654
+ }
2655
+ for (const s of screens ?? []) if (s.parts.some((n) => !names.has(n))) throw malformed();
2656
+ } else if ((screens ?? []).some((s) => s.parts.length > 0)) throw malformed();
2657
+ return {
2658
+ version: 1,
2659
+ kind: "kit",
2660
+ name: json.name,
2661
+ theme: { css: theme.css, fontImports: theme.fontImports },
2662
+ components: json.components,
2663
+ utils: json.utils,
2664
+ utilsPackages: json.utilsPackages,
2665
+ packages: json.packages,
2666
+ devPackages: json.devPackages,
2667
+ ...section ? { section } : {},
2668
+ ...screens !== void 0 ? { screens } : {},
2669
+ ...screenParts !== void 0 ? { screenParts } : {},
2670
+ ...screenIndex !== void 0 ? { screenIndex: screenIndex.map((e) => ({ slug: e.slug, title: e.title, available: e.available, kind: e.kind ?? "list", ...typeof e.action === "string" ? { action: e.action } : {} })) } : {}
2671
+ };
2672
+ }
2673
+
2674
+ // src/add/fetch-kit.ts
2675
+ async function fetchKit(opts, fetchImpl = fetch) {
2676
+ const { api, token, screens, messages } = opts;
2677
+ const asAll = screens === "all" || Array.isArray(screens) && (screens.includes("all") || new Set(screens).size > SCREENS_QUERY_MAX);
2678
+ const query = screens === void 0 || Array.isArray(screens) && screens.length === 0 ? "" : `?screens=${encodeURIComponent(asAll ? "all" : screens.join(","))}`;
2679
+ const path = `${opts.path ?? "/api/kit"}${query}${query === "" ? "?" : "&"}pages=1`;
2680
+ return validateKitManifest(await getJson({ api, token, path, ...messages ? { messages } : {} }, fetchImpl));
2681
+ }
2682
+
2551
2683
  // src/add/plan-packages.ts
2552
2684
  function componentClosure(picked, manifest) {
2553
2685
  const byName = new Map(manifest.components.map((c) => [c.name, c]));
@@ -2617,8 +2749,13 @@ var SCREEN_PART_EDITED = (slug, part) => `Skipped screen "${slug}": you edited s
2617
2749
  var SCREEN_PAIR_EDITED = (slug, editedPath) => `Skipped screen "${slug}": you edited ${editedPath} and the kit has since changed the file beside it, so they would no longer fit together. Run again with --force to replace both.`;
2618
2750
  var SCREEN_PART_EDITED_FOR_AGENT = (slug, part) => `Skipped screen "${slug}": the user edited screens/parts/${part} and the kit's version has changed since. Tell the user; they can replace it by running npx designsource add --force themselves.`;
2619
2751
  var SCREEN_PAIR_EDITED_FOR_AGENT = (slug, editedPath) => `Skipped screen "${slug}": the user edited ${editedPath} and the kit has since changed the file beside it, so they would no longer fit together. Tell the user; they can replace both by running npx designsource add --force themselves.`;
2752
+ var SITE_PART_EDITED = (part) => `Skipped the site menu: you edited screens/parts/${part} and the kit's version has changed since. Run again with --force to replace it.`;
2753
+ var SITE_PART_EDITED_FOR_AGENT = (part) => `Skipped the site menu: the user edited screens/parts/${part} and the kit's version has changed since. Tell the user; they can replace it by running npx designsource add --force themselves.`;
2620
2754
  var SHELL_FILE = "app-shell.tsx";
2621
2755
  var SHELL_STAMP = "screen:shell";
2756
+ var SITE_FILE = "site-shell.tsx";
2757
+ var SITE_STAMP = "screen:site";
2758
+ var SITE_PART_NAMES = ["site-frame", "site-links"];
2622
2759
  function stampAt(root, path) {
2623
2760
  const abs = resolveInside(root, path);
2624
2761
  if (!existsSync8(abs)) return null;
@@ -2650,11 +2787,12 @@ var stampsIn = (root, dir, ext) => {
2650
2787
  return found;
2651
2788
  };
2652
2789
  function screensOnDisk(root, t) {
2653
- const out = { slugs: [], parts: /* @__PURE__ */ new Map(), shell: false };
2790
+ const out = { slugs: [], parts: /* @__PURE__ */ new Map(), shell: false, site: false };
2654
2791
  if (t.componentsDir === null) return out;
2655
2792
  const dir = `${t.componentsDir}/screens`;
2656
2793
  for (const s of stampsIn(root, dir, /\.tsx$/)) {
2657
2794
  if (s.name === SHELL_STAMP) out.shell ||= s.path === `${dir}/${SHELL_FILE}`;
2795
+ else if (s.name === SITE_STAMP) out.site ||= s.path === `${dir}/${SITE_FILE}`;
2658
2796
  else if (s.name.startsWith("screen:") && !s.name.endsWith(".data")) out.slugs.push(s.name.slice("screen:".length));
2659
2797
  }
2660
2798
  for (const p of stampsIn(root, `${dir}/parts`, /\.tsx?$/)) {
@@ -2674,6 +2812,10 @@ function closureOf(names, byName) {
2674
2812
  names.forEach(visit);
2675
2813
  return [...seen.values()];
2676
2814
  }
2815
+ function sitePartsOf(manifest) {
2816
+ const byName = new Map((manifest.screenParts ?? []).map((p) => [p.name, p]));
2817
+ return byName.has("site-frame") ? closureOf(SITE_PART_NAMES.filter((n) => byName.has(n)), byName) : [];
2818
+ }
2677
2819
  function screenPartsOf(screen, manifest) {
2678
2820
  return closureOf(screen.parts, new Map((manifest.screenParts ?? []).map((p) => [p.name, p])));
2679
2821
  }
@@ -2683,15 +2825,19 @@ function planScreenFiles(a) {
2683
2825
  const dir = `${t.componentsDir}/screens`;
2684
2826
  const byName = new Map((manifest.screenParts ?? []).map((p) => [p.name, p]));
2685
2827
  const disk = screensOnDisk(root, t);
2686
- const plan = { write: [], edited: [], foreign: [], skipped: [], gone: [], kitComponents: [], added: [] };
2828
+ const plan = { write: [], edited: [], foreign: [], skipped: [], gone: [], kitComponents: [], added: [], siteParts: [], siteSkipped: null };
2687
2829
  const rewritten = (p) => rewriteForApp(p.contents, t);
2830
+ const editedAndChanged = (p) => {
2831
+ const on = disk.parts.get(p.name);
2832
+ return on !== void 0 && on.edited && on.hash !== hashOf(rewritten(p));
2833
+ };
2688
2834
  const written = [];
2835
+ const kindOf = new Map((manifest.screenIndex ?? []).map((e) => [e.slug, e.kind]));
2689
2836
  for (const screen of (manifest.screens ?? []).filter((s) => wanted.includes(s.slug))) {
2690
- const parts = closureOf(screen.parts, byName);
2691
- const blocker = force ? void 0 : parts.find((p) => {
2692
- const on = disk.parts.get(p.name);
2693
- return on !== void 0 && on.edited && on.hash !== hashOf(rewritten(p));
2694
- });
2837
+ const page = isPageKind(kindOf.get(screen.slug) ?? "");
2838
+ const withFrame = page && byName.has("site-frame");
2839
+ const parts = closureOf(withFrame ? [...screen.parts, "site-frame"] : screen.parts, byName);
2840
+ const blocker = force ? void 0 : parts.find(editedAndChanged);
2695
2841
  if (blocker) {
2696
2842
  plan.skipped.push({ slug: screen.slug, reason: SCREEN_PART_EDITED(screen.slug, blocker.file), agentReason: SCREEN_PART_EDITED_FOR_AGENT(screen.slug, blocker.file) });
2697
2843
  continue;
@@ -2709,7 +2855,7 @@ function planScreenFiles(a) {
2709
2855
  continue;
2710
2856
  }
2711
2857
  const kept = force ? files : files.filter((f, i) => !(f.current && files[1 - i].edited));
2712
- written.push({ slug: screen.slug, component: screen.component, parts, files: kept });
2858
+ written.push({ slug: screen.slug, component: screen.component, page, parts, files: kept });
2713
2859
  }
2714
2860
  const push = (path, name, contents, component, screen) => {
2715
2861
  const abs = resolveInside(root, path);
@@ -2719,21 +2865,31 @@ function planScreenFiles(a) {
2719
2865
  else if (status === "edited") plan.edited.push(path);
2720
2866
  };
2721
2867
  const partsDone = /* @__PURE__ */ new Set();
2868
+ const pushPart = (p) => {
2869
+ if (partsDone.has(p.name)) return;
2870
+ partsDone.add(p.name);
2871
+ const on = disk.parts.get(p.name);
2872
+ if (force || !(on && on.edited)) push(`${dir}/parts/${p.file}`, `screen-part:${p.name}`, p.contents, p.name);
2873
+ };
2722
2874
  for (const s of written) {
2723
2875
  for (const f of s.files) {
2724
2876
  const name = f.file.endsWith(".data.ts") ? `screen:${s.slug}.data` : `screen:${s.slug}`;
2725
2877
  push(`${dir}/${f.file}`, name, f.contents, s.slug, s.slug);
2726
2878
  }
2727
- plan.added.push({ slug: s.slug, component: s.component, importPath: `${t.componentsAlias}/screens/${s.slug}` });
2728
- for (const p of s.parts) {
2729
- if (partsDone.has(p.name)) continue;
2730
- partsDone.add(p.name);
2731
- const on = disk.parts.get(p.name);
2732
- if (force || !(on && on.edited)) push(`${dir}/parts/${p.file}`, `screen-part:${p.name}`, p.contents, p.name);
2879
+ plan.added.push({ slug: s.slug, component: s.component, importPath: `${t.componentsAlias}/screens/${s.slug}`, ...s.page ? { page: true } : {} });
2880
+ s.parts.forEach(pushPart);
2881
+ }
2882
+ if (a.site) {
2883
+ const parts = sitePartsOf(manifest);
2884
+ const blocker = force ? void 0 : parts.find(editedAndChanged);
2885
+ if (blocker) plan.siteSkipped = { reason: SITE_PART_EDITED(blocker.file), agentReason: SITE_PART_EDITED_FOR_AGENT(blocker.file) };
2886
+ else {
2887
+ plan.siteParts = parts;
2888
+ parts.forEach(pushPart);
2733
2889
  }
2734
2890
  }
2735
2891
  const kitComponents = /* @__PURE__ */ new Set();
2736
- for (const s of written) for (const p of s.parts) for (const k of p.kitImports) kitComponents.add(k);
2892
+ for (const p of [...written.flatMap((s) => s.parts), ...plan.siteParts]) for (const k of p.kitImports) kitComponents.add(k);
2737
2893
  plan.kitComponents = [...kitComponents].sort();
2738
2894
  const inIndex = new Set((manifest.screenIndex ?? []).map((e) => e.slug));
2739
2895
  plan.gone = manifest.screenIndex === void 0 ? [] : disk.slugs.filter((s) => !inIndex.has(s));
@@ -2754,6 +2910,27 @@ function planShellFile(a) {
2754
2910
  const contents = stampContents(SHELL_STAMP, rewriteForApp(assembleAppShell({ name: a.name, screens: a.screens, hrefFor: "root" }), t));
2755
2911
  return { path, contents, status: existingFileStatus(resolveInside(a.root, path)), importPath: `${t.componentsAlias}/screens/app-shell` };
2756
2912
  }
2913
+ function sitePagesFor(slugs, index) {
2914
+ const bySlug = new Map((index ?? []).map((e) => [e.slug, e]));
2915
+ const kinds = /* @__PURE__ */ new Set();
2916
+ const pages = [];
2917
+ const valid = [...new Set(slugs)].filter((s) => SCREEN_SLUG.test(s) && !RESERVED_SCREEN_SLUGS.includes(s));
2918
+ for (const slug of valid.sort((a, b) => a < b ? -1 : a > b ? 1 : 0)) {
2919
+ const e = bySlug.get(slug);
2920
+ if (!e || !isPageKind(e.kind) || kinds.has(e.kind)) continue;
2921
+ kinds.add(e.kind);
2922
+ pages.push({ slug, title: e.title, kind: e.kind });
2923
+ }
2924
+ return pages;
2925
+ }
2926
+ function planSiteFile(a) {
2927
+ const { targets: t } = a;
2928
+ if (t.componentsDir === null) throw new CliError(SCREENS_NEED_COMPONENTS_DIR(t.componentsAlias));
2929
+ const path = `${t.componentsDir}/screens/${SITE_FILE}`;
2930
+ const source = assembleSiteShell({ name: a.name, pages: a.pages, year: a.year, ...a.action !== void 0 ? { fallbackActionLabel: a.action } : {} });
2931
+ const contents = stampContents(SITE_STAMP, rewriteForApp(source, t));
2932
+ return { path, contents, status: existingFileStatus(resolveInside(a.root, path)), importPath: `${t.componentsAlias}/screens/site-shell` };
2933
+ }
2757
2934
 
2758
2935
  // src/add/css-blocks.ts
2759
2936
  var isSpace = (c) => c === " " || c === " " || c === "\n" || c === "\r" || c === "\f";
@@ -3101,8 +3278,24 @@ var SHELL_EMPTY = "The app shell lists no screens yet: each one you add with des
3101
3278
  var SHELL_EMPTY_FOR_AGENT = "The app shell lists no screens yet: call add_ui_kit with screens to pull some first; each one joins its menu.";
3102
3279
  var SHELL_COMPONENTS = ["sidebar", "icons"];
3103
3280
  var SHELL_SKIPPED = (reason) => `Skipped the app shell: ${reason}.`;
3281
+ var SITE_SKIPPED = (reason) => `Skipped the site menu: ${reason}.`;
3104
3282
  var SHELL_NOT_IN_KIT = (name) => `the kit from this DS source server has no ${name}`;
3105
3283
  var NO_SCREENS_YET = (project) => `${printable(project)} has no screens yet. Make one in the Screens view of the workbench.`;
3284
+ var NO_PAGES_YET = (project) => `${printable(project)} has no pages yet. Make one with Ask AI on the Screens view in DS source, then run this again.`;
3285
+ var NO_PAGES_PULLED = (project, page) => `None of ${printable(project)}'s pages is in this app yet, and the site menu links only the pages here. ${page === null ? "None of them can be built now: pick another version of one in DS source, then run this again." : `Pull a page with it: npx designsource add --screen ${printable(page)},site`}`;
3286
+ var PAGE_SKIPPED_NO_SITE = (skipLine) => `${skipLine} The site menu links only the pages in this app, so it was not written either.`;
3287
+ var screenSkipText = (slug, reason) => reason.startsWith("Skipped screen ") ? reason : `Skipped screen "${slug}": ${reason}`;
3288
+ var NoPagesPulledError = class extends CliError {
3289
+ constructor(project, page, skip) {
3290
+ super(skip ? PAGE_SKIPPED_NO_SITE(screenSkipText(skip.slug, skip.reason)) : NO_PAGES_PULLED(project, page));
3291
+ this.project = project;
3292
+ this.page = page;
3293
+ this.skip = skip;
3294
+ }
3295
+ project;
3296
+ page;
3297
+ skip;
3298
+ };
3106
3299
  var UNKNOWN_SCREENS_SHOWN = 10;
3107
3300
  var UNKNOWN_SCREENS = (names, index, project) => {
3108
3301
  const head = `No screen${names.length === 1 ? "" : "s"} named ${names.map((n) => `"${printable(n)}"`).join(", ")} in ${printable(project)}.`;
@@ -3178,14 +3371,16 @@ async function chooseComponents(input, manifest, before, sectionOnDisk, question
3178
3371
  }
3179
3372
  function screensQuery(input, disk) {
3180
3373
  if (input.screens !== void 0) return input.screens === "all" || input.screens.length > 0 ? input.screens : void 0;
3181
- if (!input.shell && (!input.refreshScreens || input.components.length > 0)) return void 0;
3374
+ if (!input.shell && !input.site && (!input.refreshScreens || input.components.length > 0)) return void 0;
3182
3375
  const slugs = disk.slugs.filter((s) => SCREEN_SLUG.test(s) && !RESERVED_SCREEN_SLUGS.includes(s));
3183
- return slugs.length > 0 ? slugs : void 0;
3376
+ if (slugs.length > 0) return slugs;
3377
+ return input.site ? "all" : void 0;
3184
3378
  }
3185
3379
  function screenConflict(slug, manifest, appDeps) {
3186
3380
  const screen = manifest.screens?.find((s) => s.slug === slug);
3187
- if (!screen) return null;
3188
- const parts = screenPartsOf(screen, manifest);
3381
+ return screen ? partsConflict(screenPartsOf(screen, manifest), manifest, appDeps) : null;
3382
+ }
3383
+ function partsConflict(parts, manifest, appDeps) {
3189
3384
  const byName = new Map(manifest.components.map((c) => [c.name, c]));
3190
3385
  const components = componentClosure(parts.flatMap((p) => p.kitImports).filter((n) => byName.has(n)), manifest);
3191
3386
  for (const pkg of [...parts.flatMap((p) => p.packages), ...components.flatMap((n) => byName.get(n)?.packages ?? [])]) {
@@ -3198,12 +3393,14 @@ function screenConflict(slug, manifest, appDeps) {
3198
3393
  return null;
3199
3394
  }
3200
3395
  function screenInstalls(slugs, manifest, appDeps) {
3396
+ const screens = (manifest.screens ?? []).filter((s) => slugs.includes(s.slug));
3397
+ return partInstalls(screens.flatMap((s) => screenPartsOf(s, manifest)), manifest, appDeps);
3398
+ }
3399
+ function partInstalls(parts, manifest, appDeps) {
3201
3400
  const install = {};
3202
- for (const screen of (manifest.screens ?? []).filter((s) => slugs.includes(s.slug))) {
3203
- for (const pkg of screenPartsOf(screen, manifest).flatMap((p) => p.packages)) {
3204
- const need = manifest.packages[pkg];
3205
- if (need !== void 0 && appDeps[pkg] === void 0) install[pkg] = need;
3206
- }
3401
+ for (const pkg of parts.flatMap((p) => p.packages)) {
3402
+ const need = manifest.packages[pkg];
3403
+ if (need !== void 0 && appDeps[pkg] === void 0) install[pkg] = need;
3207
3404
  }
3208
3405
  return install;
3209
3406
  }
@@ -3290,18 +3487,36 @@ async function runAdd(input, deps) {
3290
3487
  const disk = screensOnDisk(root, planned);
3291
3488
  const query = screensQuery(input, disk);
3292
3489
  const manifest = await fetchKit({ api: input.api, token: input.token, path: input.kitPath, messages: input.messages, screens: query }, deps.fetchImpl);
3293
- const shellAlone = input.shell === true && input.screens === void 0;
3294
- const screenSelection = query === void 0 ? null : shellAlone ? { wanted: [], skipped: [] } : selectScreens(query, input.screens !== void 0, manifest, info.deps);
3295
- const screenPlan = screenSelection === null ? null : planScreenFiles({ root, targets: planned, manifest, wanted: screenSelection.wanted, force: input.force });
3490
+ const indexOnly = (input.shell === true || input.site === true) && input.screens === void 0;
3491
+ if (input.site) {
3492
+ if (manifest.screenIndex === void 0) throw new CliError(SCREENS_NOT_SERVED);
3493
+ if (!manifest.screenIndex.some((e) => isPageKind(e.kind))) throw new CliError(NO_PAGES_YET(manifest.name));
3494
+ }
3495
+ const screenSelection = query === void 0 ? null : indexOnly ? { wanted: [], skipped: [] } : selectScreens(query, input.screens !== void 0, manifest, info.deps);
3296
3496
  const fetchedScreens = query !== void 0 && manifest.screenIndex !== void 0;
3297
- const screensAfter = shellScreensFor([...disk.slugs, ...(screenPlan?.added ?? []).map((a) => a.slug)], manifest.screenIndex);
3298
- const bareRerun = input.refreshScreens === true && input.components.length === 0 && input.screens === void 0 && !input.shell;
3497
+ const siteWanted = input.site === true || disk.site && fetchedScreens;
3498
+ const siteConflict = siteWanted ? partsConflict(sitePartsOf(manifest), manifest, info.deps) : null;
3499
+ const screenPlan = screenSelection === null ? null : planScreenFiles({ root, targets: planned, manifest, wanted: screenSelection.wanted, force: input.force, site: siteWanted && siteConflict === null });
3500
+ const slugsAfter = [...disk.slugs, ...(screenPlan?.added ?? []).map((a) => a.slug)];
3501
+ const screensAfter = shellScreensFor(slugsAfter, manifest.screenIndex);
3502
+ const sitePages = sitePagesFor(slugsAfter, manifest.screenIndex);
3503
+ if (input.site && sitePages.length === 0) {
3504
+ const pageSlugs = new Set(manifest.screenIndex.filter((e) => isPageKind(e.kind)).map((e) => e.slug));
3505
+ const namedSkip = [...screenSelection?.skipped ?? [], ...screenPlan?.skipped ?? []].find((k) => pageSlugs.has(k.slug)) ?? null;
3506
+ const first = manifest.screenIndex.find((e) => isPageKind(e.kind) && e.available);
3507
+ throw new NoPagesPulledError(manifest.name, first?.slug ?? null, namedSkip);
3508
+ }
3509
+ const bareRerun = input.refreshScreens === true && input.components.length === 0 && input.screens === void 0 && !input.shell && !input.site;
3299
3510
  const noScreensLeft = bareRerun && screensAfter.length === 0;
3300
3511
  const listScreens2 = fetchedScreens || noScreensLeft;
3301
3512
  const writeShell = input.shell === true || disk.shell && listScreens2;
3302
3513
  const shellPlan = writeShell ? planShellFile({ root, targets: planned, name: manifest.name, screens: screensAfter }) : null;
3514
+ const siteSkipped = siteConflict !== null ? { reason: SITE_SKIPPED(siteConflict) } : screenPlan?.siteSkipped ?? null;
3515
+ const writeSite = (input.site === true || disk.site && listScreens2) && siteSkipped === null;
3516
+ const siteListed = noScreensLeft ? [] : sitePages;
3517
+ const sitePlan = writeSite ? planSiteFile({ root, targets: planned, pages: siteListed, ...registrySite(manifest) }) : null;
3303
3518
  const onDisk = sectionPresent(root, planned);
3304
- const screensOnly = (input.screens !== void 0 || input.shell === true) && input.components.length === 0 && !input.all && !onDisk.present;
3519
+ const screensOnly = (input.screens !== void 0 || input.shell === true || input.site === true) && input.components.length === 0 && !input.all && !onDisk.present;
3305
3520
  const chosen = await chooseComponents(input, manifest, previouslyAdded(root, planned), onDisk.present, deps.questions, {
3306
3521
  components: [...screenPlan?.kitComponents ?? [], ...shellPlan ? SHELL_COMPONENTS : []],
3307
3522
  only: screensOnly
@@ -3322,10 +3537,10 @@ async function runAdd(input, deps) {
3322
3537
  (name) => !manifest.components.some((c) => c.name === name) ? SHELL_NOT_IN_KIT(name) : packages.skipped.find((k) => k.name === name)?.reason ?? null
3323
3538
  ).find((r) => r !== null) ?? null;
3324
3539
  const shellToWrite = shellBlocker === null ? shellPlan : null;
3325
- const registryAlone = !writeSection && onDisk.present && fetchedScreens && (screenPlan?.write.length ?? 0) > 0 && planned.componentsDir !== null && sectionReadsScreens(root, planned) ? registryFile(planned.componentsDir, planned, screensAfter) : null;
3540
+ const registryAlone = !writeSection && onDisk.present && fetchedScreens && (screenPlan?.write.length ?? 0) > 0 && planned.componentsDir !== null && sectionReadsScreens(root, planned) ? registryFile(planned.componentsDir, planned, screensAfter, registrySite(manifest)) : null;
3326
3541
  const plan = planFiles(root, planned, componentClosure(packages.components, manifest), manifest);
3327
3542
  const sectionStatus = [...writeSection ? section.paths : [], ...registryAlone ? [registryAlone.path] : []].filter((p) => !p.endsWith(".json")).map((p) => [p, existingFileStatus(resolveInside(root, p))]);
3328
- const shellStatus = shellToWrite ? [[shellToWrite.path, shellToWrite.status]] : [];
3543
+ const shellStatus = [...shellToWrite ? [shellToWrite] : [], ...sitePlan ? [sitePlan] : []].map((f) => [f.path, f.status]);
3329
3544
  const setup = planSetup(info, manifest, deps.exec);
3330
3545
  if (writeSection && info.framework === "vite") {
3331
3546
  try {
@@ -3367,13 +3582,14 @@ async function runAdd(input, deps) {
3367
3582
  if (writeSection && info.framework !== "vite" && !dark.known) sectionNote = UNKNOWN_DARK(dark.selector ?? "");
3368
3583
  const sectionWrites = [...writeSection ? section.files(dark.marker) : [], ...registryAlone ? [registryAlone] : []].filter((f) => !kept.includes(f.path));
3369
3584
  const shellWrite = shellToWrite && !kept.includes(shellToWrite.path) ? shellToWrite : null;
3585
+ const siteWrite = sitePlan && !kept.includes(sitePlan.path) ? sitePlan : null;
3370
3586
  const registryWritten = listScreens2 && planned.componentsDir !== null && sectionWrites.some((f) => f.path === registryPath(planned.componentsDir));
3371
3587
  const removeScaffolding = info.shadcn !== null || hasThemeRegion(sheet);
3372
3588
  const themed = applyTheme(sheet, manifest.theme, { preflight: setup.preflight, removeScaffolding });
3373
3589
  try {
3374
3590
  writeFiles(
3375
3591
  root,
3376
- [{ path: planned.cssFile, contents: themed.css }, ...[...writes, ...sectionWrites, ...screenWrites, ...shellWrite ? [shellWrite] : []].map(({ path, contents }) => ({ path, contents }))],
3592
+ [{ path: planned.cssFile, contents: themed.css }, ...[...writes, ...sectionWrites, ...screenWrites, ...shellWrite ? [shellWrite] : [], ...siteWrite ? [siteWrite] : []].map(({ path, contents }) => ({ path, contents }))],
3377
3593
  { force: true, created: false }
3378
3594
  );
3379
3595
  } catch (e) {
@@ -3388,7 +3604,12 @@ async function runAdd(input, deps) {
3388
3604
  const screensAdded = (screenPlan?.added ?? []).filter((a) => screenWrites.some((w) => w.screen === a.slug));
3389
3605
  if (screensAdded.length > 0) deps.progress(`Adding ${screensAdded.length} screen${screensAdded.length === 1 ? "" : "s"}\u2026 \u2713`);
3390
3606
  if (shellWrite) deps.progress("Adding the app shell\u2026 \u2713");
3391
- const install = { ...packages.install, ...screenInstalls((screenPlan?.added ?? []).map((s) => s.slug), manifest, info.deps) };
3607
+ if (siteWrite) deps.progress("Adding the site menu\u2026 \u2713");
3608
+ const install = {
3609
+ ...packages.install,
3610
+ ...screenInstalls((screenPlan?.added ?? []).map((s) => s.slug), manifest, info.deps),
3611
+ ...partInstalls(screenPlan?.siteParts ?? [], manifest, info.deps)
3612
+ };
3392
3613
  const reactIs = manifest.packages["react-is"];
3393
3614
  if ("recharts" in install && reactIs !== void 0 && info.deps["react-is"] === void 0) install["react-is"] = reactIs;
3394
3615
  const commands = installCommands(info, manifest, install);
@@ -3427,24 +3648,34 @@ async function runAdd(input, deps) {
3427
3648
  routeDir: info.framework === "next" ? nextAppDir(root) : null
3428
3649
  },
3429
3650
  screensView: registryWritten && screensAfter.length > 0 ? info.framework === "vite" ? "/design-system.html#/screens" : "/design-system/screens" : null,
3430
- shell: shellWrite ? { importPath: shellWrite.importPath, screens: screensAfter.length } : null,
3431
- shellNote: shellBlocker === null ? null : SHELL_SKIPPED(shellBlocker)
3651
+ // The app shell lists app screens alone: pages have the site menu.
3652
+ shell: shellWrite ? { importPath: shellWrite.importPath, screens: screensAfter.filter((s) => !isPageKind(s.kind)).length } : null,
3653
+ shellNote: shellBlocker === null ? null : SHELL_SKIPPED(shellBlocker),
3654
+ site: siteWrite ? { importPath: siteWrite.importPath, pages: siteListed.length } : null,
3655
+ siteSkipped,
3656
+ siteOnDisk: disk.site || siteWrite !== null
3432
3657
  };
3433
3658
  }
3434
3659
 
3435
3660
  // src/add/summary.ts
3436
3661
  var leftBlocksLine = (n, reader) => `Left ${n} block${n === 1 ? "" : "s"} in place; ${reader === "agent" ? "no_blocks" : "--no-blocks"} does not remove ${n === 1 ? "it" : "them"}.`;
3437
3662
  var sectionNoteFor = (note, reader) => reader === "agent" && note === SECTION_NEEDS_FULL_KIT ? SECTION_NEEDS_FULL_KIT_FOR_AGENT : note;
3438
- var screenSkipLine = (s, reader) => {
3439
- const reason = reader === "agent" && s.agentReason ? s.agentReason : s.reason;
3440
- return reason.startsWith("Skipped screen ") ? reason : `Skipped screen "${s.slug}": ${reason}`;
3663
+ var screenSkipLine = (s, reader) => screenSkipText(s.slug, reader === "agent" && s.agentReason ? s.agentReason : s.reason);
3664
+ var GET_SITE_SHELL = {
3665
+ cli: "Get <SiteShell> with npx designsource add --screen site.",
3666
+ agent: 'Get <SiteShell>: call add_ui_kit with screens ["site"].'
3441
3667
  };
3442
- function screenLines(r, reader) {
3443
- const first = r.added[0];
3668
+ function screenLines(r, reader, siteOnDisk) {
3669
+ const first = r.added.find((s) => !s.page);
3444
3670
  const mount = !first ? [] : r.routeDir !== null ? [`Mount a screen on a route: ${r.routeDir}/${first.slug}/page.tsx \u2192 export { ${first.component} as default } from '${first.importPath}'`] : [`Render <${first.component} /> where you want it.`];
3671
+ const pages = !r.added.some((s) => s.page) ? [] : [
3672
+ r.routeDir !== null ? `Mount each page on its own route inside <SiteShell>: ${r.routeDir}/page.tsx for the home page, ${r.routeDir}/<name>/page.tsx for the others. Never inside the app shell.` : "Render each page on its own route inside <SiteShell>, never inside the app shell.",
3673
+ ...siteOnDisk ? [] : [GET_SITE_SHELL[reader]]
3674
+ ];
3445
3675
  return [
3446
3676
  ...r.added.map((s) => `import { ${s.component} } from '${s.importPath}'`),
3447
3677
  ...mount,
3678
+ ...pages,
3448
3679
  ...r.kept.map((path) => `Kept your edits to ${path}`),
3449
3680
  ...r.skipped.map((skip) => screenSkipLine(skip, reader)),
3450
3681
  ...r.gone.map((slug) => `Screen "${printable(slug)}" is no longer in DS source; left it in place`)
@@ -3460,10 +3691,12 @@ function summaryLines(r, reader = "cli") {
3460
3691
  ...r.section?.blocksLeftInPlace ? [leftBlocksLine(r.section.blocks, reader)] : [],
3461
3692
  ...r.section ? [`Your design system: ${r.section.path}`] : [],
3462
3693
  ...r.sectionNote ? [sectionNoteFor(r.sectionNote, reader)] : [],
3463
- ...r.screens ? screenLines(r.screens, reader) : [],
3694
+ ...r.screens ? screenLines(r.screens, reader, r.siteOnDisk) : [],
3464
3695
  ...r.screensView ? [`Your screens: ${r.screensView}`] : [],
3465
3696
  ...r.shell ? [`import { AppShell } from '${r.shell.importPath}'`, ...r.shell.screens === 0 ? [reader === "agent" ? SHELL_EMPTY_FOR_AGENT : SHELL_EMPTY] : []] : [],
3466
3697
  ...r.shellNote ? [r.shellNote] : [],
3698
+ ...r.site ? [`import { SiteShell } from '${r.site.importPath}'`] : [],
3699
+ ...r.siteSkipped ? [reader === "agent" && r.siteSkipped.agentReason ? r.siteSkipped.agentReason : r.siteSkipped.reason] : [],
3467
3700
  `Done. Your components now use "${r.projectName}" from designsource.app.`,
3468
3701
  "Run it again any time to pull updates."
3469
3702
  ];
@@ -3966,7 +4199,7 @@ function validateManifest(json) {
3966
4199
 
3967
4200
  // src/fetch-manifest.ts
3968
4201
  async function fetchManifest(opts, fetchImpl = fetch) {
3969
- const query = { framework: opts.framework, ...opts.name ? { name: opts.name } : {}, ...opts.screens ? { screens: opts.screens } : {} };
4202
+ const query = { framework: opts.framework, ...opts.name ? { name: opts.name } : {}, ...opts.screens ? { screens: opts.screens, pages: "1" } : {} };
3970
4203
  return validateManifest(await getJson({ api: opts.api, token: opts.token, path: "/api/starter", query }, fetchImpl));
3971
4204
  }
3972
4205
 
@@ -4081,7 +4314,7 @@ async function runAddCommand(args, io, exec = spawnExec, store) {
4081
4314
  const targets = info.shadcn ? resolveTargets(root, info.shadcn) : defaultTargets(root, info);
4082
4315
  assertKitUtils(root, info, targets);
4083
4316
  let mode;
4084
- if (interactive && args.components.length === 0 && !args.all && args.screens === void 0 && !args.shell) {
4317
+ if (interactive && args.components.length === 0 && !args.all && args.screens === void 0 && !args.shell && !args.site) {
4085
4318
  const first = previouslyAdded(root, targets).every((n) => n === "utils") && !sectionPresent(root, targets).present;
4086
4319
  if (first) mode = await pick(PICK_QUESTION, ADD_MODES, 0);
4087
4320
  }
@@ -4099,6 +4332,7 @@ async function runAddCommand(args, io, exec = spawnExec, store) {
4099
4332
  blocks: !args.noBlocks,
4100
4333
  screens: args.screens,
4101
4334
  shell: args.shell,
4335
+ site: args.site,
4102
4336
  refreshScreens: true,
4103
4337
  force: args.force
4104
4338
  },
@@ -4688,7 +4922,7 @@ async function runLogout(args, io, deps = defaultLoginDeps(process.env)) {
4688
4922
  import { homedir as homedir4 } from "node:os";
4689
4923
 
4690
4924
  // src/version.ts
4691
- var VERSION = true ? "0.10.0" : "0.0.0-dev";
4925
+ var VERSION = true ? "0.11.0" : "0.0.0-dev";
4692
4926
 
4693
4927
  // src/mcp/account-session.ts
4694
4928
  var NOT_SIGNED_IN_FOR = (root) => `Not signed in on this computer for ${printable(root)}. Ask the user to run npx designsource login in a terminal in that folder, then restart this app.`;
@@ -4957,7 +5191,7 @@ var fundingRefusal = (body, api) => {
4957
5191
  if (!isPlainObject(body) || !FUNDING_CODES.includes(String(body.code))) return null;
4958
5192
  return errorResult(`${serverText(body) ?? "This account cannot pay for a screen right now."} ${FUNDING_HINT(api)}`);
4959
5193
  };
4960
- var GENERATE_DESCRIPTION = "Make a new app screen for the design system this folder is linked to, from a sentence (a list, a detail page, settings, a form or a dashboard built from its components), or change an existing one by passing its name in screen. Pass data_model to shape the screen's records after the app's own (read from its Prisma schema or types). Spends the signed-in account's credits or its own AI key, so your client will ask the user first, and takes up to a couple of minutes. Never writes files: the answer names the screen and a link to see it; then call add_ui_kit with screens to write it into the app.";
5194
+ var GENERATE_DESCRIPTION = "Make a new app screen for the design system this folder is linked to, from a sentence (a list, a detail page, settings, a form or a dashboard built from its components), or a marketing page (home, pricing or waitlist: one of each kind), or change an existing screen or page by passing its name in screen. Pass data_model to shape the screen's records after the app's own (read from its Prisma schema or types). Spends the signed-in account's credits or its own AI key, so your client will ask the user first, and takes up to a couple of minutes. Never writes files: the answer names the screen and a link to see it; then call add_ui_kit with screens to write it into the app.";
4961
5195
  async function generateScreen(args, ctx) {
4962
5196
  if (!ctx.account) return errorResult(ctx.accountRefusal ?? GENERATE_NEEDS_LOGIN);
4963
5197
  const account = ctx.account;
@@ -4972,7 +5206,7 @@ async function generateScreen(args, ctx) {
4972
5206
  if (!Array.isArray(projects)) return projects;
4973
5207
  const project = projects.find((p) => p.id === projectId);
4974
5208
  if (!project) return errorResult(LINKED_PROJECT_GONE);
4975
- const body = { prompt, operationId: randomUUID() };
5209
+ const body = { prompt, operationId: randomUUID(), pages: true };
4976
5210
  if (screen !== void 0) body.screen = screen;
4977
5211
  if (dataModel !== void 0) body.dataModel = dataModel;
4978
5212
  const outcome = await postNdjson({ api: account.api, path: generatePath(projectId), token: account.token, body }, ctx.fetchImpl);
@@ -5119,8 +5353,13 @@ var isScreenName2 = (v) => typeof v === "string" && SCREEN_SLUG.test(v) && !RESE
5119
5353
  var SCREENS_NOT_LISTED = "This DS source server does not list screens yet.";
5120
5354
  var NO_SCREENS_LISTED = "This design system has no screens yet. Make one with generate_screen (after the user signs in with npx designsource login), or in the Screens view of the workbench.";
5121
5355
  var SCREEN_NAME_ARG = '"screen" must be a screen name from list_screens.';
5122
- var SCREENS_ARG = '"screens" must be screen names from list_screens, or ["all"].';
5356
+ var SCREENS_ARG = '"screens" must be screen names from list_screens, "site", or ["all"].';
5123
5357
  var SCREENS_NOT_SERVED_FOR_AGENT = "This DS source server does not send screens yet. Call add_ui_kit without screens.";
5358
+ var NO_PAGES_PULLED_FOR_AGENT = (e) => {
5359
+ if (e.skip) return PAGE_SKIPPED_NO_SITE(screenSkipText(e.skip.slug, e.skip.agentReason ?? e.skip.reason));
5360
+ const head = "None of this design system's pages is in the app yet, and the site menu links only the pages there.";
5361
+ return e.page === null ? `${head} None of them can be built now: ask the user to pick another version of one in DS source.` : `${head} Call add_ui_kit with screens ["${e.page}", "site"] to pull a page with it.`;
5362
+ };
5124
5363
  function listScreens(snapshot) {
5125
5364
  if (!snapshot.screens) return errorResult(SCREENS_NOT_LISTED);
5126
5365
  if (snapshot.screens.length === 0) return textResult(NO_SCREENS_LISTED);
@@ -5162,11 +5401,13 @@ async function getScreenSource(args, ctx) {
5162
5401
  );
5163
5402
  }
5164
5403
  function screensArg(v) {
5165
- if (v === void 0) return { ok: true, value: void 0 };
5404
+ if (v === void 0) return { ok: true, value: void 0, site: false };
5166
5405
  if (!Array.isArray(v) || !v.every((n) => typeof n === "string")) return { ok: false };
5167
- if (v.includes("all")) return { ok: true, value: "all" };
5168
- if (!v.every(isScreenName2)) return { ok: false };
5169
- return { ok: true, value: v.length > 0 ? [...new Set(v)] : void 0 };
5406
+ const site = v.includes("site");
5407
+ const names = v.filter((n) => n !== "site");
5408
+ if (names.includes("all")) return { ok: true, value: "all", site };
5409
+ if (!names.every(isScreenName2)) return { ok: false };
5410
+ return { ok: true, value: names.length > 0 ? [...new Set(names)] : void 0, site };
5170
5411
  }
5171
5412
  async function addUiKit(args, ctx) {
5172
5413
  const { components, replace_existing: replace, no_blocks: noBlocks } = args;
@@ -5200,6 +5441,7 @@ async function addUiKit(args, ctx) {
5200
5441
  skipInstall: false,
5201
5442
  blocks: noBlocks !== true,
5202
5443
  ...screens.value !== void 0 ? { screens: screens.value } : {},
5444
+ ...screens.site ? { site: true } : {},
5203
5445
  // As a bare CLI rerun: a call naming neither components nor screens refreshes the screens an earlier run wrote.
5204
5446
  refreshScreens: true
5205
5447
  },
@@ -5216,7 +5458,7 @@ async function addUiKit(args, ctx) {
5216
5458
  );
5217
5459
  } catch (e) {
5218
5460
  if (!(e instanceof CliError) && progress.length === 0) throw e;
5219
- const message = e instanceof UnknownComponentsError ? UNKNOWN_FOR_AGENT(e.names) : e instanceof CliError && e.message === SCREENS_NOT_SERVED ? SCREENS_NOT_SERVED_FOR_AGENT : e instanceof Error ? e.message : String(e);
5461
+ const message = e instanceof UnknownComponentsError ? UNKNOWN_FOR_AGENT(e.names) : e instanceof CliError && e.message === SCREENS_NOT_SERVED ? SCREENS_NOT_SERVED_FOR_AGENT : e instanceof NoPagesPulledError ? NO_PAGES_PULLED_FOR_AGENT(e) : e instanceof Error ? e.message : String(e);
5220
5462
  const tail = e instanceof StepError && e.outputTail ? ["Last output:", e.outputTail] : [];
5221
5463
  return errorResult([...progress, message, ...tail].join("\n"));
5222
5464
  }
@@ -5341,7 +5583,7 @@ ${files.join("\n\n")}`);
5341
5583
  },
5342
5584
  {
5343
5585
  name: "list_screens",
5344
- description: "The app screens made for this design system in DS source (lists, details, settings, forms, dashboards built from the kit): one line each, name \u2014 title (kind). Follow with get_screen_source, or write them into the app with add_ui_kit and screens.",
5586
+ description: 'The app screens made for this design system in DS source (lists, details, settings, forms, dashboards built from the kit): one line each, name \u2014 title (kind). Marketing pages (home, pricing, waitlist) are listed too; they mount on their own routes inside the site shell (add_ui_kit with screens including "site"). Follow with get_screen_source, or write them into the app with add_ui_kit and screens.',
5345
5587
  inputSchema: NO_INPUT,
5346
5588
  annotations: READ_ONLY,
5347
5589
  run: (snapshot) => listScreens(snapshot)
@@ -5356,14 +5598,14 @@ ${files.join("\n\n")}`);
5356
5598
  },
5357
5599
  {
5358
5600
  name: "add_ui_kit",
5359
- description: `Add this design system's UI kit to the React app in the current folder: the theme, the components and their libraries. Sets up Tailwind and shadcn when the app lacks them. A full run (no components and no screens named) also writes the /design-system section, every component, block and sample page in the project's theme, with its blocks unless no_blocks is true, and refreshes the screens an earlier run wrote. screens (names from list_screens, or ["all"]) writes those app screens with the parts and components they import; you mount each on a route. Changes files in the project, so your client will ask the user first. Never overwrites components or screens the user edited.`,
5601
+ description: `Add this design system's UI kit to the React app in the current folder: the theme, the components and their libraries. Sets up Tailwind and shadcn when the app lacks them. A full run (no components and no screens named) also writes the /design-system section, every component, block and sample page in the project's theme, with its blocks unless no_blocks is true, and refreshes the screens an earlier run wrote. screens (names from list_screens, or ["all"]) writes those app screens and marketing pages with the parts and components they import; you mount each on a route. Add "site" to screens to write the site menu (header and footer) that pages mount inside, at least one page being pulled with it. Changes files in the project, so your client will ask the user first. Never overwrites components or screens the user edited.`,
5360
5602
  inputSchema: {
5361
5603
  type: "object",
5362
5604
  properties: {
5363
5605
  components: { type: "array", items: { type: "string" }, description: "Component names such as button or dialog. Omit to add everything (or refresh what was added before)." },
5364
5606
  replace_existing: { type: "boolean", description: "Replace component files that exist but were not added by designsource. Ask the user first." },
5365
5607
  no_blocks: { type: "boolean", description: "Add the /design-system section without its blocks and their libraries. Blocks an earlier run wrote are left in place." },
5366
- screens: { type: "array", items: { type: "string" }, description: `Screen names from list_screens, or ["all"] for every screen. Each is written under the components folder's screens/ with the parts and kit components it imports.` }
5608
+ screens: { type: "array", items: { type: "string" }, description: `Screen names from list_screens, or ["all"] for every screen; "site" adds the site menu for marketing pages. Each is written under the components folder's screens/ with the parts and kit components it imports.` }
5367
5609
  },
5368
5610
  additionalProperties: false
5369
5611
  },
@@ -5455,7 +5697,7 @@ var isObject2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
5455
5697
  var isStringRecord = (v) => isObject2(v) && Object.values(v).every((x) => typeof x === "string");
5456
5698
  var isStringListRecord = (v) => isObject2(v) && Object.values(v).every((x) => Array.isArray(x) && x.every((s) => typeof s === "string"));
5457
5699
  var isBlockEntry = (v) => isObject2(v) && typeof v.id === "string" && typeof v.title === "string" && typeof v.family === "string" && Array.isArray(v.components) && v.components.every((c) => typeof c === "string") && Array.isArray(v.files) && v.files.every((f) => typeof f === "string");
5458
- var isScreenRow = (v) => isObject2(v) && typeof v.slug === "string" && SCREEN_SLUG.test(v.slug) && !RESERVED_SCREEN_SLUGS.includes(v.slug) && typeof v.title === "string" && typeof v.kind === "string" && SCREEN_KINDS.includes(v.kind) && typeof v.updatedAt === "string";
5700
+ var isScreenRow = (v) => isObject2(v) && typeof v.slug === "string" && SCREEN_SLUG.test(v.slug) && !RESERVED_SCREEN_SLUGS.includes(v.slug) && typeof v.title === "string" && typeof v.kind === "string" && (SCREEN_KINDS.includes(v.kind) || isPageKind(v.kind)) && typeof v.updatedAt === "string";
5459
5701
  var isScreenIndex = (v) => Array.isArray(v) && v.every(isScreenRow) && new Set(v.map((r) => r.slug)).size === v.length;
5460
5702
  function validateSnapshot(json) {
5461
5703
  if (!isObject2(json)) throw malformed4();
@@ -5476,7 +5718,7 @@ function validateSnapshot(json) {
5476
5718
  }
5477
5719
  async function fetchSnapshot(opts, fetchImpl = fetch) {
5478
5720
  const { api, token, path = "/api/snapshot", messages } = opts;
5479
- return validateSnapshot(await getJson({ api, token, path, ...messages ? { messages } : {} }, fetchImpl));
5721
+ return validateSnapshot(await getJson({ api, token, path: `${path}?pages=1`, ...messages ? { messages } : {} }, fetchImpl));
5480
5722
  }
5481
5723
  var STALE_RETRY_MS = 15e3;
5482
5724
  var servesStale = (e) => !(e instanceof ApiError) || e.status === null || e.status >= 500;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "designsource",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "The DS source CLI: add your design system's UI kit to a React app (add), add the design system to any other app (integrate), start a new Next.js project from it (create), or serve it to a coding agent over MCP (mcp) — tokens, every component and your mockup page.",
5
5
  "license": "MIT",
6
6
  "repository": {