Docs/API Reference

API Reference

Public TypeScript, React, theme, and agent-artifact APIs for @deweydocs/dewey

Dewey’s primary product surface is the CLI: dewey init, build and check (see CLI Reference). The TypeScript API supports typed configuration for the frozen 0.4 pipeline, programmatic artifact retrieval, theme CSS, prompt templates, and an optional React presentation layer. The public module is defined by packages/docs/src/index.ts; package subpaths are defined by packages/docs/package.json.

Choose the right surface

GoalSurfaceImport or command
Set up docs, front door and siteCLIbunx dewey init
Build the site, llms.txt, .md copies and llms-full.txtCLIbunx dewey build
Check maps, reviews, references and outputsCLIbunx dewey check
Collect or build 0.4 retrieval artifacts in codeArtifact subpath@deweydocs/dewey/agent-artifacts
Render Markdown in an existing React appOptional UI@deweydocs/dewey + CSS subpaths
Style a site with a house skinCSS subpath@deweydocs/dewey/css/skins/<name>.css
Type-check a dewey.config.ts for the frozen commandsMain TypeScript module@deweydocs/dewey

The React components render Markdown for people inside an app you already have. They do not replace dewey build, which writes its own static site.

Package entry points

Package pathContents
@deweydocs/deweyConfiguration helper, themes, React components, hooks, skills, utilities, and types
@deweydocs/dewey/reactCompatibility alias for the same module as @deweydocs/dewey
@deweydocs/dewey/agent-artifactsMarkdown collection, manifests, bundles, and ownership-safe artifact writing
@deweydocs/dewey/cssFull CSS bundle
@deweydocs/dewey/stylesAlias for the full CSS bundle
@deweydocs/dewey/css/base.cssBase component styles
@deweydocs/dewey/css/tokensSemantic --dw-* tokens
@deweydocs/dewey/css/tailwindTailwind-oriented CSS
@deweydocs/dewey/css/colors/<theme>.cssOne published color preset
@deweydocs/dewey/css/skins/<name>.cssOne site skin: dewey, openscout, talkie, lattices, hudsonkit, atlas, endpoint, terminal
@deweydocs/dewey/tailwindTailwind preset module

There is no wildcard color export. <theme> must be one of the fourteen published names listed under Themes.

Configuration API

defineConfig parses and returns a DeweyConfig; it is not just a TypeScript identity helper. dewey.config.ts is read only by the frozen commands (audit, generate, agent, create, update, eject); init, build and check use .dewey/project.json instead. Invalid values throw a Zod validation error. Its source is packages/docs/src/cli/schema.ts.

// dewey.config.tsimport { defineConfig } from '@deweydocs/dewey'export default defineConfig({  project: {    name: 'my-library',    tagline: 'A useful TypeScript library',    type: 'npm-package',    version: '1.0.0',  },  agent: {    criticalContext: ['Use Bun for package operations'],    entryPoints: { API: 'src/index.ts', Tests: 'test/' },    rules: [      { pattern: '*.test.ts', instruction: 'Use bun:test.' },    ],    sections: [], // empty means all human-readable docs  },  docs: {    path: './docs',    output: './',    required: ['overview', 'quickstart', 'api'],  },  install: {    objective: 'Install my-library.',    prerequisites: ['Node.js 18+'],    steps: [{ description: 'Install', command: 'bun add my-library' }],    doneWhen: { command: 'bun test', expectedOutput: 'all tests pass' },  },})

DeweyConfig

FieldTypeDefault / requirement
project.namestringRequired
project.taglinestringOptional
project.typeProjectType'generic'
project.versionstringOptional
agent.criticalContextstring[][]
agent.entryPointsRecord<string, string>{}
agent.rules{ pattern: string; instruction: string }[][]
agent.sectionsstring[][]; empty includes every human-readable document
docs.pathstring'./docs'
docs.outputstring'./'
docs.requiredstring[]['overview', 'quickstart']
install.objectivestringOptional
install.doneWhen{ command: string; expectedOutput?: string }Optional
install.prerequisitesstring[][]
install.stepsInstall step array[]
install.hostedUrlstringOptional

ProjectType is 'macos-app' | 'npm-package' | 'cli-tool' | 'react-library' | 'monorepo' | 'generic'.

Programmatic agent artifacts

Import this surface from @deweydocs/dewey/agent-artifacts, implemented in packages/docs/src/cli/agent-artifacts.ts.

import {  buildAgentManifest,  collectMarkdownArtifacts,  getMarkdownArtifact,  writeAgentArtifacts,} from '@deweydocs/dewey/agent-artifacts'const options = {  rootDir: process.cwd(),  docsDir: './docs',}const project = { name: 'my-library', version: '1.0.0' }const docs = await collectMarkdownArtifacts(options)const manifest = buildAgentManifest(docs, { project })const api = await getMarkdownArtifact('api', options)const preview = await writeAgentArtifacts({  ...options,  outputDir: './generated',  project,  dryRun: true,})console.log(manifest.recommendedReadOrder, api?.rawUrl, preview.operations)

dryRun: true plans the same ownership-aware operations without writing. A real write creates or updates Dewey-owned outputs and prunes stale outputs in the selected artifact scope; overwrite: true explicitly permits replacement of reviewed desired-output conflicts, including modified or unowned targets.

Artifact functions

ExportSignature / result
collectMarkdownArtifacts(options?)Recursively parse .md and .mdx; returns sorted Promise<MarkdownArtifact[]>
getMarkdownArtifact(slug, options?)Find by normalized slug or source path; returns Promise<MarkdownArtifact | null>
getPromptArtifact(promptId, options?)Find a prompt under prompts/; returns Promise<MarkdownArtifact | null>
parseDocArtifact(filePath, raw?, options?)Parse one file or supplied Markdown string into a MarkdownArtifact
buildAgentManifest(docs, options?)Build an AgentManifest; includeContent controls embedded Markdown/content
buildPromptRegistry(docs, options?)Build the schema-versioned prompt registry
buildContextBundle(docs, slugs, title?)Render selected slugs as one Markdown bundle
buildAgentArtifactFiles(options?)Build generated file descriptions in memory without applying them
writeAgentArtifacts(options?)Plan and optionally apply artifact writes; returns counts, paths, and operations

Artifact types and classification

CollectMarkdownArtifactsOptions accepts rootDir? and docsDir?. WriteAgentArtifactsOptions adds outputDir?, project?, dryRun?, and overwrite?. AgentArtifactsProject is { name: string; version?: string; tagline?: string; repository?: string }.

MarkdownArtifactKind is 'doc' | 'agent' | 'prompt' | 'reference' | 'proposal'. Classification is path-based:

Path patternKind
prompts/**prompt
agent/** or a slug ending in .agentagent
reference/**reference
proposals/**proposal
Everything elsedoc

A MarkdownArtifact includes id, slug, kind, optional promptId, title/description, sourcePath, retrieval URLs, frontmatter, headings, token estimate, raw Markdown, and body content. Manifest types exported by the subpath are AgentManifest, AgentManifestEntry, PromptManifestEntry, MarkdownArtifact, MarkdownHeading, and the option/project types above.

React API

React is an optional presentation layer. The main source is packages/docs/src/index.ts; component contracts live in packages/docs/src/components/.

'use client'import {  AutoTableOfContents,  CopyButtons,  DeweyProvider,  MarkdownContent,} from '@deweydocs/dewey'import '@deweydocs/dewey/css/base.css'import '@deweydocs/dewey/css/tokens'import '@deweydocs/dewey/css/colors/ocean.css'export function DocPage({ markdown, agentMarkdown }: {  markdown: string  agentMarkdown: string}) {  return (    <DeweyProvider theme="ocean">      <CopyButtons markdownContent={markdown} agentContent={agentMarkdown} />      <MarkdownContent content={markdown} />      <AutoTableOfContents markdown={markdown} />    </DeweyProvider>  )}

Components that call Dewey hooks must be descendants of DeweyProvider. In a Next.js App Router project, put the provider and interactive components behind a client boundary; load Markdown and generate static params on the server.

Provider and complete app

ExportRequired propsImportant optional props
DeweyProviderchildrencomponents, theme, defaultDark, storageKey
DocsAppdocs: Record<string, string>config, currentPage, providerProps; onNavigate is currently reserved and not invoked
DocsIndextree: PageNode[]projectName, tagline, description, basePath, hero, showSearch, heroIcon, quickLinks, layout

FrameworkComponents can provide a Link component accepting anchor props plus href, and an optional Image component accepting image props. ThemeConfig accepts preset?, partial colors (primary, background, foreground, accent), and partial fonts (sans, mono).

DocsAppConfig.layout.header is boolean | 'minimal'; the other layout switches are booleans: sidebar, toc, footer, prevNext, and breadcrumbs.

Layout and content components

ExportRequired propsImportant optional props
HeaderNoneprojectName, homeUrl, backUrl, backLabel, label, showThemeToggle, actions
SidebartreecurrentPage, projectName, basePath, isOpen, onClose, header, footer
MarkdownContentcontentisDark
TableOfContentsNoneitems, title, className, scrollOffset
AutoTableOfContentsNonemarkdown, containerRef, title, className
DocsLayoutchildren, title, navigation, projectNameRouter-neutral shell; accepts currentPage and a framework LinkComponent, with plain anchors by default; its prop type is not re-exported by the main entry point
CodeBlock / HeadingLinkSee sourceValues are public, but their prop interfaces are not exported

TocItem is { id: string; title: string; level: number }. Related exports are useActiveSection, extractTocItems, extractTocFromDom, useTableOfContents, and extractSections.

Content and agent-friendly components

ExportRequired propsImportant optional props / unions
Calloutchildrentype?: 'info' | 'warning' | 'tip' | 'danger', title
Tabs / Tabchildren; Tab also requires labelTabs.defaultTab
Steps / Stepchildren; Step also requires title—
Cardtitledescription, icon, href, children
CardGridchildrencolumns?: 2 | 3 | 4
FileTreeitemsdefaultExpanded; item type?: 'file' | 'folder'
ApiTablepropertiestitle
Badgechildrenvariant, size?: 'sm' | 'md'
CopyButtonsmarkdownContentagentContent, showLabels, onCopy, className
AgentContextcontenttitle, defaultExpanded, className
PromptSlideoutisOpen, onClose, info, starterTemplatetitle, description, params, examples, expectedOutput, className

BadgeVariant is 'default' | 'success' | 'warning' | 'danger' | 'info' | 'purple'. CopyButtons.onCopy receives 'markdown' | 'agent' | 'plain'.

PageNode is a discriminated union of PageItem, PageFolder, and PageSeparator using type: 'page' | 'folder' | 'separator'. Page/navigation badge colors are 'info' | 'success' | 'warning' | 'error' | 'default'. NavigationConfig is NavigationGroup[].

Legacy compatibility types are also exported: NavItem, NavGroup, DocSection, BadgeColor, PageLink, and DocsConfig. The legacy BadgeColor union is 'blue' | 'emerald' | 'purple' | 'amber' | 'rose'.

Themes

The canonical registry is packages/docs/src/themes.ts.

import {  THEME_REGISTRY,  VALID_THEMES,  isThemeName,  resolveTheme,  type ThemeName,} from '@deweydocs/dewey'const input = process.env.DOCS_THEMEconst theme: ThemeName = resolveTheme(input) // invalid or missing -> 'neutral'if (input && !isThemeName(input)) {  console.warn(`Choose one of: ${VALID_THEMES.join(', ')}`)}console.log(THEME_REGISTRY[theme].cssFile)

ThemeName and ThemePreset contain the same values:

'neutral' | 'ocean' | 'emerald' | 'purple' | 'dusk' | 'rose' | 'github' | 'warm' | 'midnight' | 'editorial' | 'mono' | 'hudson' | 'ink' | 'slate'

PUBLISHED_CSS_THEMES lists presets with CSS exports; VALID_THEMES lists presets accepted by generated sites. Every current registry entry belongs to both lists. resolveTheme falls back to 'neutral'.

All fourteen presets resolve the same semantic contract in light and dark: surfaces/foregrounds, primary/secondary/accent pairs, border/ring, info/warning/error/success pairs, code and syntax colors, sidebar/header colors, typography, radii, shadows, and motion. Runtime components and generated sites consume semantic --dw-* variables; public components do not own literal color palettes.

Contract tests verify every preset and generated-site theme in both modes, reject missing/dead tokens, require WCAG AA text pairs and visible focus, and check reduced-motion behavior. bun run --cwd packages/docs test:visual renders representative navigation, prose, controls, semantic states, code, and tables for 14 themes × light/dark and compares 28 Playwright screenshots.

Skills and structured agent content

The skill exports are LLM prompt definitions, not deterministic generators:

ExportType / role
docsReviewAgentPrompt set for accuracy and drift review; result type DocsReviewResult
docsDesignCriticPrompt set for structure/design critique; result type DocsDesignCritiqueResult
promptSlideoutGeneratorPrompt set for authoring slideout configuration; type PromptSlideoutConfig
installMdGeneratorPrompt set for installmd.org content; type InstallMdConfig
improveAIPromptsIterative discovery/draft/review/refinement prompt set; types PromptImprovementPass and PromptQualityCriteria

improveAIPromptsSkill is a deprecated alias of improveAIPrompts for compatibility.

Structured agent content can be assembled and rendered without the CLI:

import {  agentContent,  renderAgentJson,  renderAgentMarkdown,} from '@deweydocs/dewey'const api = agentContent('api', 'API', 'Public package contracts')  .enums('Themes', { ThemePreset: ['neutral', 'ocean'] })  .code('Import', 'ts', "import { defineConfig } from '@deweydocs/dewey'")  .build()const markdown = renderAgentMarkdown(api)const json = renderAgentJson(api)

The related exports are AgentContentBuilder, renderAgentPlainText, and the AgentContent, AgentSection, TableSection, EnumSection, CodeSection, TextSection, and ListSection types.

Complete main-module export inventory

The following names are re-exported from packages/docs/src/index.ts.

GroupRuntime exports
ConfigdefineConfig
ThemesPUBLISHED_CSS_THEMES, THEME_REGISTRY, VALID_THEMES, isThemeName, resolveTheme
App/providerDocsApp, DocsAppDefault, DocsIndex, DeweyProvider, useDewey, useTheme, useComponents, useLink
Layout/contentHeader, DocsLayout, MarkdownContent, CodeBlock, HeadingLink, Sidebar, TableOfContents, AutoTableOfContents, useActiveSection, extractTocItems, extractTocFromDom
UICallout, Tabs, Tab, Steps, Step, Card, CardGrid, FileTree, ApiTable, Badge
Agent UICopyButtons, AgentContext, PromptSlideout
SkillspromptSlideoutGenerator, docsReviewAgent, docsDesignCritic, installMdGenerator, improveAIPrompts, improveAIPromptsSkill
Hooks/utilitiesuseDarkMode, useTableOfContents, extractSections, cn, resolveIcon, commonIcons
Agent contentagentContent, AgentContentBuilder, renderAgentMarkdown, renderAgentJson, renderAgentPlainText
Type groupType exports
Config/themesAgentRule, DeweyConfig, InstallConfig, ProjectType, ThemeDefinition, ThemeName, ThemePreset
App/providerDocsAppProps, DocsAppConfig, DocsIndexProps, DeweyProviderProps, DeweyContextValue, ThemeConfig, FrameworkComponents
ComponentsHeaderProps, DocsLayoutProps, MarkdownContentProps, SidebarProps, AutoTocProps, TableOfContentsProps, TocItem, CalloutProps, CalloutType, TabsProps, TabProps, StepsProps, StepProps, CardProps, CardGridProps, FileTreeProps, FileTreeItem, ApiTableProps, ApiProperty, BadgeProps, BadgeVariant, CopyButtonsProps, AgentContextProps, PromptSlideoutProps, PromptParam
Skills/contentPromptSlideoutConfig, DocsReviewResult, DocsDesignCritiqueResult, InstallMdConfig, PromptImprovementPass, PromptQualityCriteria, AgentContent, AgentSection, TableSection, EnumSection, CodeSection, TextSection, ListSection
Navigation/utilitiesPageTree, PageNode, PageItem, PageFolder, PageSeparator, FlatPage, NavigationConfig, NavigationGroup, NavigationItem, CommonIconName
LegacyNavItem, NavGroup, DocSection, BadgeColor, PageLink, DocsConfig

For command flags and workflows, use the CLI reference. For a complete server/client integration, use Integrate into an existing site.