Added
- Monorepo test suite — Root Vitest runner and config (
vitest.config.ts,pnpm test,pnpm test:watch) with a centralizedtests/layout and baseline coverage acrosscore,cli,mdx,mdc, andnext-dev. - Registry JSON Schema —
registry/schema.jsonnow exists and matches the$schemareference inregistry-index.json, enabling editor validation forversion+items. - Watcher integrations —
@document0/next-devfor Next.js dev-time content invalidation without sidecar routes;@document0/core/watchfor runtime-agnostic file watching (watchDocsSource/stopWatchingDocsSource).
Changed
- Slimmed
@document0/corebarrel export — Types, plugin, source, tree, and navigation remain in the barrel; search, llms, openapi, and graph are now only available via subpath exports (e.g.@document0/core/search). All doc examples updated accordingly. - Deduplicated MDC processor pipeline — Extracted shared
parseFrontmatter()helper inprocessor.ts, eliminating duplicated frontmatter parsing inprocessMdcandprocessMdcToHtml. - Deduplicated MDX processor pipeline — Extracted
shared.tswithparseFrontmatter(),buildRemarkPlugins(), andbuildRehypePlugins(). Bothprocessor.tsandhtml-processor.tsnow import fromshared.ts. - Typed cache on
DocsSource— Replaced the public_cachewith a private map and a typedgetOrSet<T>(key, factory)method. The search module now usesgetOrSetinstead of directly accessing the internal map. - Deduplicated
readMeta— ExtractedreadMetafromsource/index.tsinto a newcore/src/meta.tsmodule, shared by bothsource/index.tsandtree/index.ts. - Async FS throughout — Replaced all synchronous
fs.readdirSync,fs.readFileSync, andfs.existsSynccalls withfs.promisesequivalents insource/index.tsandtree/index.ts. PropagatedasyncthroughDocsSourcemethods (getPages,getPageTree,getPage,getPageByUrl,getMeta),buildPageTree, and all callers. - Type-safe OpenAPI module — Replaced unsafe
ascasts withisObj,str,bool,arrtype-guard helpers for safe property access with fallbacks. Non-object entries are now filtered out instead of silently producing wrong data. - Skip redundant frontmatter parsing —
processMdx,processMdxToHtml,processMdc, andprocessMdcToHtmlnow accept optional pre-parsed frontmatter and content, avoiding re-reading and re-parsing the raw file on every call. - CLI
add/updatepath validation —installPathmust resolve inside the current project root, each file path must resolve inside the validated install directory, and unsafe paths now fail fast with an explicit error. - CLI safe command execution — Replaced string-based
execSyncwith argument-basedexecFileSync(command, args)for dependency installs, removing shell command concatenation from registry-controlled values.
Removed
"./plugins"subpath export — Removed from@document0/core. Reading-time is now provided only via the plugin registry (registry/plugins/document0/reading-time); consumers install it with the CLI or copy the registry snippet.
Performance
- O(n)
orderByMeta— Replaced O(n²)findIndex+spliceloop with a pre-builtMap<string, TreeNode>keyed on slug tails, URL tails, and folder names. Unmatched nodes are appended in a single pass. - O(n)
buildPageTree— Pre-computedpagesByDirandchildDirsmaps replace O(n²) page filtering at each recursion level with O(1) directory lookups. - O(1)
getPageNeighbours— Added aWeakMap-cached URL→index map so lookups useMap.getinstead offindIndexon every call. - O(1)
ContentGraphlink lookups — Replaced linearlinks.filter()ingetLinks,getBacklinks, andgetBrokenLinkswithMap<string, LinkInfo[]>indexes built once at construction time. - Single-parse
processMdcToHtml— TOC is now extracted from the same HAST tree produced by a single parse+run, eliminating a redundant second pipeline pass. - Cached unified processors —
WeakMap-based processor caching keyed on the highlighter instance forprocessMdc,processMdcToHtml, andprocessMdxToHtml. The frozen processor is reused across calls, avoiding redundant pipeline construction per page.