Skip to content

Getting Started

Welcome to Speculator! This guide will help you get up and running with the core packages.

You can install the core packages using your favorite package manager.

Terminal window
pnpm add @openuji/speculator

To start using Speculator, you’ll typically use the speculate function to process a document with a set of plugins.

import { speculate, corePlugins } from "@openuji/speculator";
const result = await speculate({
entry: "path/to/spec.md",
plugins: corePlugins,
});
console.log(result.workspace);

For managing multiple isolated specifications, Speculator provides a workspace building utility. This allows you to process multiple documents at once, keeping their namespaces and references isolated.

const result = await buildWorkspaces({
entryMap: {
docs: [{ entry: "spec/core/index.md" }, { entry: "spec/api/index.html" }],
},
});
if (result.errors.length > 0) {
console.error("Errors encountered:", result.errors);
}
// Access built workspace 'docs' AST
console.log(result.workspaces.docs);

Check out the Configuration guide to learn how to structure your specs, or the API Reference for more detailed information.