Share config discovery logic between main and launcher so XDG/home and SubMiner/subminer precedence stay consistent. Add regression tests for resolution order and keep config path/show behavior stable.
4.1 KiB
id, title, status, assignee, created_date, updated_date, labels, dependencies, priority
| id | title | status | assignee | created_date | updated_date | labels | dependencies | priority | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| TASK-70 | Unify config path resolution across main and launcher | Done |
|
2026-02-18 11:35 | 2026-02-19 09:05 |
|
high |
Description
Config discovery logic is duplicated and inconsistent between app main process and launcher. Main resolves XDG_CONFIG_HOME + case variants (SubMiner/subminer), while launcher loaders still hardcode ~/.config/SubMiner in places.
Action Steps
- Extract shared config path discovery utility (candidate roots, case variants,
.jsonc/.jsonpreference). - Replace ad-hoc resolution in
src/main.ts,launcher/main.ts, andlauncher/config.ts. - Normalize fallback behavior when config file is absent.
- Keep existing user-visible behavior for
subminer config path|show. - Add tests for XDG and case-variant path resolution.
- Update docs if path precedence changes.
Acceptance Criteria
- #1 Single canonical path-resolution logic used by app and launcher
- #2
XDG_CONFIG_HOMEandSubMiner|subminerprecedence covered by tests - #3 No behavior drift for existing config-path CLI commands
Implementation Plan
- Add focused precedence tests in
src/config/path-resolution.test.tsfor XDG/home base-dir order, SubMiner/subminer fallbacks, config.jsonc/config.json preference, and fallback path behavior. - Create canonical helper module
src/config/path-resolution.tsexporting shared discovery functions for config dir and config file resolution. - Replace duplicated path-resolution logic in
src/main.ts,launcher/main.ts, and launcher config loaders inlauncher/config.tsto use the canonical helper. - Verify no behavior drift with
bun run build, config/path tests, and launcher bundle build; then update backlog acceptance/DoD checks and execution notes.
Implementation Notes
2026-02-19T08:52:23Z: Started task execution; gathering code context for unified config-path resolution across main and launcher.
Plan captured in docs/plans/2026-02-19-task-70-unify-config-path-resolution.md and recorded in task. User requested immediate execution after planning.
Implemented canonical config path discovery in src/config/path-resolution.ts and switched src/main.ts, launcher/main.ts, and launcher config loaders in launcher/config.ts to use it.
Added precedence regression coverage in src/config/path-resolution.test.ts and wired into test:config:dist.
Verification passed: bun run build, node --test dist/config/path-resolution.test.js dist/config/config.test.js, and bun build ./launcher/main.ts --target=bun --packages=bundle --outfile=/tmp/subminer-task70.
Final Summary
Unified config discovery behind a single canonical utility at src/config/path-resolution.ts and replaced duplicated resolvers in src/main.ts, launcher/main.ts, and launcher config loaders in launcher/config.ts. This keeps XDG_CONFIG_HOME + ~/.config base-dir handling, SubMiner|subminer case variants, and config.jsonc > config.json file preference consistent across app and launcher while preserving subminer config path|show fallback output behavior.
Added regression tests in src/config/path-resolution.test.ts for base-dir trimming/dedup, candidate precedence, lowercase fallback, directory fallback for main config dir resolution, and fallback file-path behavior; wired the new suite into test:config:dist in package.json.
Verification run: bun run build, node --test dist/config/path-resolution.test.js dist/config/config.test.js, bun build ./launcher/main.ts --target=bun --packages=bundle --outfile=/tmp/subminer-task70 (all pass).
Definition of Done
- #1 Launcher and config tests pass
- #2 Code no longer duplicates config path candidate logic