Configuration schema and loader. Defines the closedcode config shape and merges layered sources (global, project .closedcode, env) into the effective configuration consumed across the app.

Classes

Service

Members

(static, constant) ConfigDirectoryTypoError

Named error raised when a config directory path appears to be a typo, carrying the offending path, directory, and a suggested correction.

(static, constant) Info

The canonical Effect Schema describing the full closedcode configuration shape. Carries a derived .zod strict-object compatibility surface for Express validators.

(static, constant) Layout

Zod-compatible schema for the (deprecated) layout config value.

(static, constant) Server

Zod-compatible schema for the server config section.

(static, constant) defaultLayer

The config layer with all of its dependency layers (filesystem, env, auth, account, npm, flock) provided, ready to be used standalone.

(static, constant) layer

Effect Layer that builds the Service: loads and merges global, custom, project-local, console/org, and managed config sources, resolves plugins, and exposes accessors (get, getGlobal, getConsoleState, directories, waitForDependencies) and mutators (update, updateGlobal, invalidate).

Methods

(inner) globalConfigFile() → {string}

Resolve the path of the global config file, preferring an existing closedcode.jsonc/closedcode.json/config.json under the global config dir, and falling back to the first candidate when none exist.

Returns:

The chosen global config file path.

Type: 
string

(inner) mergeConfig(target, source) → {Object}

Deep-merge two config objects, with source values overriding target.

Parameters:
NameTypeDescription
targetObject

Base config object.

sourceObject

Config object whose values take precedence.

Returns:

The merged config object.

Type: 
Object

(inner) mergeConfigConcatArrays(target, source) → {Object}

Deep-merge two config objects but union their instructions arrays instead of letting source replace target's array.

Parameters:
NameTypeDescription
targetObject

Base config object.

sourceObject

Config object whose values take precedence.

Returns:

The merged config object with concatenated instructions.

Type: 
Object

(inner) normalizeLoadedConfig(data, source) → {*}

Strip deprecated TUI-related keys (theme, keybinds, tui) from a loaded config record, logging a deprecation warning when any are present.

Parameters:
NameTypeDescription
data*

The raw parsed config value (only normalized when a record).

sourcestring

Path/source identifier used in the deprecation warning.

Returns:

A copy of the config without the legacy keys, or the input unchanged when not a record.

Type: 
*

(inner) patchJsonc(input, patch, path) → {string}

Apply a (possibly nested) patch object onto a JSONC document string while preserving comments and formatting, recursing through record values to build the JSON path for each leaf edit.

Parameters:
NameTypeDescription
inputstring

The original JSONC document text.

patch*

The patch value; records are recursed, leaves are written at path.

pathArray.<string>

The current JSON property path (accumulated during recursion).

Returns:

The updated JSONC document text.

Type: 
string

(async, inner) resolveLoadedPlugins(config, filepath) → {Promise.<Object>}

Resolve each plugin spec in a loaded config relative to the file that declared it, so path-like specs (e.g. ./plugin.mjs) keep their original base location.

Parameters:
NameTypeDescription
configObject

The loaded config object, possibly containing a plugin array.

filepathstring

Path of the config file that declared the plugins.

Returns:

The same config object with plugin specs resolved in place.

Type: 
Promise.<Object>

(inner) writable(info) → {Object}

Produce a writable copy of a config object by dropping the internal plugin_origins provenance metadata that should never be persisted.

Parameters:
NameTypeDescription
infoObject

The config object, possibly containing plugin_origins.

Returns:

A copy of the config without plugin_origins.

Type: 
Object

(inner) writableGlobal(info) → {Object}

Produce a writable copy of a config object for persisting to the global file, additionally clearing an empty-string shell so a blank key is not written.

Parameters:
NameTypeDescription
infoObject

The config object to make writable.

Returns:

A copy suitable for serializing to the global config file.

Type: 
Object