Skip to content

SDK overview

The expgov CLI is a thin host over @expgov/core — pure domain logic with no Commander dependency and no console.* in command paths. Use the SDK to embed inventory, diff, validate, trend, timeline, and graph in scripts, CI, workers, or your own tools.

Install

bash
pnpm add -D @expgov/core
# or: npm install -D @expgov/core
typescript
import { runValidate } from '@expgov/core';
import { initProjectContext } from '@expgov/core/internal';

CLI package (@expgov/cli)

bash
pnpm add -D @expgov/cli
typescript
// optional — plain object export works; types recommended for editor checking
import { defineConfig } from '@expgov/cli/core';
GoalInstall
CLI + config types (@expgov/cli/core)@expgov/cli as devDep
Programmatic run* command APIs@expgov/core as devDep

See Install for why the CLI publishes as @expgov/cli (npm blocks unscoped expgov as too similar to expo).

Host contract

  1. initProjectContext({ cwd, config }) — from @expgov/core/internal; loads expgov.config.ts via jiti.
  2. setRunOptions@expgov/core/internal; --json, --quiet, cache flags, list truncation.
  3. run* command APIs — from @expgov/core (stable); returns exit code where applicable.
  4. subscribeLogSink@expgov/core/internal; optional human report lines.
SubpathRole
@expgov/coreStable — defineConfig, run* command APIs, config/JSON types, ExportError
@expgov/core/advancedTooling — config resolve, init helpers, help formatters
@expgov/core/internalCLI host — project context, run options, log sinks, style

Programmatic commands

FunctionCLI equivalent
runInventoryexpgov inventory
runDiffexpgov diff
runValidateexpgov validate
runTrendexpgov trend
runTimelineexpgov timeline
runGraphexpgov graph
runSuggestexpgov suggest
runDoctorexpgov doctor

Example (validate in CI)

ts
import { runValidate } from '@expgov/core';
import {
  initProjectContext,
  setRunOptions,
  resetRunOptions,
} from '@expgov/core/internal';

initProjectContext({ cwd: process.cwd() });
setRunOptions({ json: true, quiet: true });
const exitCode = runValidate();
resetRunOptions();
process.exit(exitCode);