Skip to main content

Interface: ConfigLoader

Defined in: packages/core/src/application/ports/config-loader.ts:20

Port for loading and resolving the active specd.yaml configuration.

Implementations live in infrastructure/:

  • FsConfigLoader — discovers specd.yaml by walking up from a directory, honours specd.local.yaml overrides, and validates the parsed YAML before constructing a SpecdConfig.

Delivery mechanisms receive a ConfigLoader instance and call load() once at startup, then pass the resulting SpecdConfig to createKernel() or individual use-case factory functions.

Two modes:

  • Discovery mode ({ startDir }) — walks up from startDir, bounded by the nearest git repository root, to find specd.yaml or specd.local.yaml.
  • Forced mode ({ configPath }) — uses the specified file directly.

Methods

load()

load(): Promise<SpecdConfig>

Defined in: packages/core/src/application/ports/config-loader.ts:27

Loads, validates, and returns the fully-resolved project configuration.

Returns

Promise<SpecdConfig>

The resolved SpecdConfig with all paths made absolute

Throws

ConfigValidationError When no config file is found or the YAML is invalid


resolvePath()

resolvePath(): Promise<string | null>

Defined in: packages/core/src/application/ports/config-loader.ts:46

Resolves the path to the active config file without loading or parsing it.

  • Discovery mode: runs the same directory walk as load() (honouring specd.local.yaml, bounded by git root). Returns the found path, or null if no file is found. Never throws.
  • Forced mode: returns the resolved absolute path directly. Does not check whether the file exists. Never throws.
  • Adapters without a local file (e.g. remote adapters): return null.

The purpose of this method is to allow delivery mechanisms to probe for config presence before deciding to dispatch to a default action (such as auto-showing the project dashboard), without paying the cost of a full load and without silencing load errors for explicitly-provided paths.

Returns

Promise<string | null>

Absolute path to the config file, or null if not locatable