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
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.
The chosen global config file path.
- Type:
- string
(inner) mergeConfig(target, source) → {Object}
Deep-merge two config objects, with source values overriding target.
| Name | Type | Description |
|---|---|---|
target | Object | Base config object. |
source | Object | Config object whose values take precedence. |
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.
| Name | Type | Description |
|---|---|---|
target | Object | Base config object. |
source | Object | Config object whose values take precedence. |
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.
| Name | Type | Description |
|---|---|---|
data | * | The raw parsed config value (only normalized when a record). |
source | string | Path/source identifier used in the deprecation warning. |
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.
| Name | Type | Description |
|---|---|---|
input | string | The original JSONC document text. |
patch | * | The patch value; records are recursed, leaves are written at |
path | Array.<string> | The current JSON property path (accumulated during recursion). |
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.
| Name | Type | Description |
|---|---|---|
config | Object | The loaded config object, possibly containing a |
filepath | string | Path of the config file that declared the plugins. |
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.
| Name | Type | Description |
|---|---|---|
info | Object | The config object, possibly containing |
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.
| Name | Type | Description |
|---|---|---|
info | Object | The config object to make writable. |
A copy suitable for serializing to the global config file.
- Type:
- Object