API reference
Core engine API
The deterministic CLI blocks: config, generators, validator, planner, LLM providers.
46 modules, 291 documented exports. Version v0.9. All packages.
packages/core
- api-composerModule 2 — Public API Composer. Exports: checkPublicApiDrift, summaryForSpecifier, syncPublicApi
- architecture-enforcerEpic 1.2 — Layer Boundary Enforcer Exports: detectLayerViolations, extractImports, findTransitionHoles, hasFactoryCall, isProviderHookName, isTrackedStateHookName, resolveRelativeImport, validateArchitecture, ...
- architecture-graphEpic 1.1 — Layer Graph Definition Exports: CANONICAL_LAYERS, PSEUDO_LAYERS, canImport, classifyFile, classifyProjectFile, loadLayerGraph, mergeLayers, validateGraph
- block-contractthe uniform block contract: `{ id, writes, declaredScope, actions, run }`. Exports: ActionRule, Block, BlockAction, DeclaredScope, ACTION_KINDS, BLOCK_ERROR_CODES, GUARDRAILS, defineBlock, ...
- block-flowsPLAN_FLOWS seen through the block contract (block-contract.mjs), by DERIVING a block from each flow entry rather than rewriting the registry: PLAN_FLOWS, validatePlan and planToCommand are untouched, so a plan means e... Exports: processLifecycleBlock, SCOPE_KINDS, flowBlock, flowBlocks, flowScopeKind
- cliExports: READ_ONLY_ATTRIBUTION, create, doctor, feature, generate, importCommand, importRouteWizard, init, ...
- configExports: DATA_LAYER_PROVIDERS, DEFAULT_EXECUTION_MODE, DEFAULT_LAYERS, DEFAULT_RULES, EXECUTION_MODES, FRAMEWORKS, REACT_SPA_LAYERS, findProjectRoot, ...
- diagnosticsExports: ConstructError, EXIT_CODES, assertValidViolation, exitCodeForViolations, formatReport, formatViolation, makeViolation, setExitCode, ...
- 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
- import-repairdeterministic repair of relative imports a model got almost right. Exports: repairRelativeImports
- import-reviewa read-only review of an import: does what was written still do what the approved plan and the source file said? Exports: buildReviewPrompt, reviewImport
- importImport capability — scaffolds a vertical slice for an existing, non-Construct file. Exports: analyzeFiles, analyzeRoute, autoFixViolations, buildFixPlan, buildFixPrompt, executeImportPlan, importPlan, importVertical, ...
- 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, MAX_OLLAMA_CONTEXT, MIN_OLLAMA_CONTEXT, PROVIDERS, callLlm, ollamaContextFor, ...
- mechanical-planthe import plan, computed without a model. Exports: classify, planMechanically, readSignals
- 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, ...
- plan-touchesthe files a writing plan step will create, worked out from its own arguments, so a plan built in the Cockpit can declare them (the approval gate refuses any file a plan did not declare, approvalGate.mjs check 2). Exports: DERIVED_FLOWS, expectedFiles
- 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, ...
- scaffold`construct init` lays down a minimal, runnable project shell for the chosen framework (package.json, tsconfig, bundler config, .gitignore, ...) next to the architecture folders, so a developer can `npm install && npm... Exports: SCAFFOLD_FRAMEWORKS, scaffoldProject
- 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
- type-checkTYPE-001: a real TypeScript type-check as an opt-in `construct validate` rule. Exports: TYPE_CHECK_TIMEOUT_MS, parseTscOutput, resolveProjectTsc, resolveReference, runTypeCheck, runTypeCheckDetailed, solutionReferences
- 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