API reference
Core engine API
The deterministic CLI blocks: config, generators, validator, planner, LLM providers.
38 modules, 236 documented exports. Version v0.8. All packages.
packages/core
- api-composerModule 2 — Public API Composer. Exports: checkPublicApiDrift, syncPublicApi
- architecture-enforcerEpic 1.2 — Layer Boundary Enforcer Exports: detectLayerViolations, extractImports, hasFactoryCall, isProviderHookName, isTrackedStateHookName, resolveRelativeImport, validateArchitecture, classifyFile, ...
- architecture-graphEpic 1.1 — Layer Graph Definition Exports: CANONICAL_LAYERS, PSEUDO_LAYERS, canImport, classifyFile, classifyProjectFile, loadLayerGraph, mergeLayers, validateGraph
- cliExports: create, doctor, feature, generate, importCommand, importRouteWizard, init, pipeline, ...
- configExports: DATA_LAYER_PROVIDERS, DEFAULT_EXECUTION_MODE, DEFAULT_LAYERS, DEFAULT_RULES, EXECUTION_MODES, FRAMEWORKS, REACT_SPA_LAYERS, findProjectRoot, ...
- diagnostics'info' is a real finding worth showing but never a validation failure -- exitCodeForViolations below only ever fails a run on 'error', so adding it here never changes what makes `construct validate` exit non-zero. Exports: ConstructError, EXIT_CODES, assertValidViolation, exitCodeForViolations, formatReport, formatViolation, makeViolation
- dir-browserAllowlisted, directories-only filesystem browser. Exports: DirBrowseError, DEFAULT_LIMIT, MAX_LIMIT, detectProject, isInside, listDirectories, normalizeRoots, resolveAllowedPath
- docsPackagesMaps a source path onto Construct's own generated API reference — deterministic, no network, no LLM. Exports: PACKAGES, docsPathFor, findDocsRepoRoot, packageForRelativePath
- exceptionsScoped, time-boxed rule exceptions (architecture.yml `exceptions:`), shared by every enforcer (architecture, separation-of-concerns, readability). Exports: exceptionApplies, expiredExceptionViolations, validateExceptionsShape
- exportArchitectureRules(extends #437, part of #500's typed-contracts epic) -- exports a project's resolved architecture.yml layer graph (packages/core/config.mjs's DEFAULT_LAYERS/canImport model, as merged by architecture-graph.mjs's loadLa... Exports: TYPES_ELEMENT_PATTERN, boundariesDependencyPolicies, boundariesElements, exportBoundariesConfig, exportBoundariesConfigFromGraph, generateEslintFlatConfigModule
- extractExpression(part of #500's Phase 3a) -- a real, mechanical ts-morph-shaped codemod (same TypeScript-compiler-API-backed approach packages/engine/tsFileMove.mjs already adopted for `construct refactor move/rename` per #435 -- thi... Exports: extractExpression, subjectOf
- file-change-trackerIn-memory "last known content" store that turns a stream of observed file contents into per-file change records. Exports: createChangeTracker
- frozen-detector"wrap, don't duplicate": detects a page/component/controller that reimplements markup already present in a frozen (externally-authored) source instead of being a thin import + prop-forward around it. Exports: DEFAULT_THRESHOLDS, FROZEN_RULE_BY_LAYER, buildFrozenIndex, detectFrozenViolations
- frozenFrozen presentation -- externally-authored source (a design tool's synced output, e.g. Exports: assertNotFrozen, listFrozenFiles, matchFrozen, normalizeFrozen, readFrozenGlobs, resolveFrozenGlob
- fsExports: ensureDir, rel, walk, write
- generatorsExports: FOLDER_TO_LAYER, LAYER_CONSTRAINTS, LAYER_ORDER, LAYER_PREREQUISITES, assertLayerPrerequisites, createFeature, extractExpressionHint, fillGeneratedFile, ...
- globConstruct's path-glob matching -- the one place `**` / `*` globs (layer patterns in architecture.yml, exception `path` globs, readability/SoC exemptions, the pages editor's page-layer check) become regular expressions. Exports: globToRegExp, matchGlob
- impactPublic entry point for the "impact" capability (`@line/construct-core/impact`). Exports: analyzeImpact, impactApiManifest, impactFromChangedFiles, impactFromTicketText, proposeSeedsFromText, renderImpactMarkdown
- importImport capability — scaffolds a vertical slice for an existing, non-Construct file. Exports: analyzeFiles, analyzeRoute, executeImportPlan, importPlan, importVertical, normalizePlanLayers, validatePlanShape
- line-sourceA minimal, hand-rolled line reader — shared by the REPL's main loop and the standalone `import --route` wizard. Exports: makeLineSource
- llm-fillShared "ask an LLM for one file's full text, but never trust it blindly" step, used by both import.mjs's per-file fill and generators.mjs's fillGeneratedFile. Exports: OUTPUT_CONTRACT, extractCode, requestFileText, whyNotCode
- llmThe one deliberate exception to "Construct makes no LLM calls" — and even here, scoped as tight as possible: this module does nothing but run a single prompt through a chosen provider's configured executor and return... Exports: DEFAULT_LLM_TIMEOUT_SEC, DEFAULT_OLLAMA_BASE_URL, DEFAULT_OLLAMA_MODEL, PROVIDERS, callLlm, resolveLlmTimeoutMs, stripCodeFence
- nonLayerNon-layer paths: `nonLayer: [<glob>, ...]` in architecture.yml declares paths that live INSIDE a feature but OUTSIDE the layer graph -- today `features/*/tests/**` (generated and authored end-to-end tests). Exports: GENERATED_TESTS_GLOB, TESTS_GLOB, isNonLayerPath, normalizeNonLayer, readNonLayerGlobs
- parserShared source-parsing engine. Exports: Summary, EXT, classifyLayer, createSummaryCache, estimateComplexity, extractExports, extractJsdoc, layerContextFor, ...
- planthe Execution Plan contract (schemas/plan.v1.json). Exports: PLAN_ERROR_CODES, PLAN_EXECUTORS, PLAN_FLOWS, PLAN_REQUIRED_FIELDS, PLAN_TOP_LEVEL_FIELDS, PLAN_VERSION, STEP_FIELDS, STEP_REQUIRED_FIELDS, ...
- proseDeterministic, template-based code -> plain-English translator (no LLM). Exports: describeExpr, describeImplementation, describeStatement, joinEnglishList
- readability-enforcerReadability/naming-convention enforcement, built on packages/core/parser.mjs. Exports: READABILITY_RULES, validateReadability
- refactorRefactor capability — mechanical, LLM-free structural moves within a Construct project. Exports: moveLayerFile, renameLayerFile
- registryPluggable enforcer registry for `construct validate`. Exports: Enforcer, EnforcerResult, aggregateValidation
- replInteractive front-end over the exact same functions packages/cli/construct.mjs dispatches to for a one-shot invocation — no new command logic lives here, only line-reading, tokenizing, help text, and a `cd`/`pwd` conv... Exports: HELP_TOPICS, TOPIC_ORDER, getTopLevelHelpText, startRepl
- route-resolverRoute resolution — a set of small, atomic, deterministic tools for going from "a Next.js route" to "the files that actually power it," so import's analysis gets a real dependency graph instead of a hand-picked directory. Exports: DEFAULT_TRACE_EXCLUDES, findControllerFile, findReactSpaRoutesFile, findRouteEntryFile, parseReactSpaRoutes, readPathAliases, resolveImportSpecifier, resolveRoute, ...
- service-generatorTicket 7.5 — Configurable Service Generator (OpenAPI -> RTKQ, services/). Exports: ensureClient, generateServiceFromSpec, parseOperations, renderClient, renderEndpoints
- soc-enforcerModule 2 — Separation of Concerns Enforcer (Epics 2.1 and 2.2). Exports: LAYER_FOLDERS, countPrimaryExports, isPublicPath, parseIndexExports, validateSeparationOfConcerns
- summarizeSummarization output for humans and AI agents, built on packages/core/parser.mjs. Exports: describeExport, extractDeclarationSource, summarizeCompact, summarizeProject, summarizeProse, summarizeSince
- text-diffPure before/after text diff -> a renderer-agnostic view model. Exports: buildDiffView
- timingCheap wall-clock timing helpers shared by every generation/scaffolding command's console output -- process.hrtime.bigint() deltas, no new dependency. Exports: elapsedSeconds, formatDuration, startTimer
- usageThe one-shot CLI's top-level usage text (printed by packages/cli/construct.mjs when invoked with no command, or an unrecognized one). Exports: USAGE
- validatePublic entry point for the "validate" capability (`@line/construct-core/validate`). Exports: DEFAULT_ENFORCERS, aggregateValidation, ConstructError, EXIT_CODES, exitCodeForViolations, formatReport, validateArchitecture