Skip to content

feat: expand configuration discovery across project, user, and system scopes #61

Description

@kjanat

Summary

DreamCLI already provides deterministic, first-match configuration discovery, but its default search is limited to the current working directory and one runtime-resolved user configuration directory. Expand the default discovery model to cover conventional project-local .config/ files, parent projects, platform-native user locations, and system-level fallbacks while keeping the core runtime-agnostic.

Current behavior

Default discovery currently supports:

  • an explicit --config <path> override, which skips discovery;
  • ./.{appName}.{ext};
  • ./{appName}.config.{ext};
  • {configDir}/{appName}/config.{ext};
  • $XDG_CONFIG_HOME with ~/.config fallback on non-Windows platforms;
  • %APPDATA% with %USERPROFILE%\\AppData\\Roaming fallback on Windows;
  • JSON out of the box and additional formats through registered loaders;
  • caller-supplied search paths; and
  • deterministic first-match behavior without merging.

Gaps

  • No walk from a configurable starting directory up to the filesystem root.
  • No project-level <dir>/.config/{appName}.{ext} candidate.
  • macOS is treated like other non-Windows platforms, so there is no ~/Library/Application Support/{appName}/config.{ext} fallback.
  • No system-level candidate such as /etc/{appName}/config.{ext} on Linux.
  • Discovery is anchored only to cwd; consumers such as editor integrations cannot anchor it to the directory of a specific file without constructing their own path list.
  • No supported mechanism for extracting an app-specific section from a host configuration file. If this belongs in the generic framework, it should likely be an explicit extractor/source hook rather than a hard-coded package or file format.

Proposed behavior

  1. Preserve explicit --config as the highest-priority exact-path override.
  2. Accept a discovery base directory, defaulting to cwd.
  3. Starting at that directory, probe each directory up to the filesystem root, nearest first:
    • .{appName}.{ext}
    • {appName}.config.{ext}
    • .config/{appName}.{ext}
  4. If no project configuration is found, probe platform-appropriate user locations.
  5. If no user configuration is found, probe supported system locations.
  6. Keep first-match/no-merge semantics and document precedence across both locations and registered formats.
  7. Keep filesystem and platform behavior behind RuntimeAdapter; src/core/ must remain runtime-agnostic.

The embedded-section/source-hook question can be split into a follow-up if it would make this change too broad.

Acceptance criteria

  • Exact search order is specified and covered by tests.
  • Project discovery walks ancestors from a caller-selectable base directory.
  • .config/{appName}.{ext} works at each project level.
  • XDG, macOS, and Windows user-directory behavior is explicitly covered.
  • Supported Linux system fallback behavior is documented and tested.
  • Explicit paths, custom search paths, custom loaders, parse errors, and first-match semantics retain their current guarantees.
  • Node, Bun, and Deno adapters expose consistent behavior.
  • User-facing configuration documentation lists every default candidate and its precedence.

References

Metadata

Metadata

Assignees

Labels

area: configConfig discovery, package metadata, and loadersarea: runtimeNode, Bun, Deno adapters and runtime detectionkind: featureNew capability or product enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions