From ebd68da7dfd6d4f2ef6c6b29a62ec848bbf15cef Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Wed, 3 Jun 2026 16:08:40 +0900 Subject: feat(config): merge home-directory global dispatch.toml under project config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Load an optional global config at ~/.config/dispatch/dispatch.toml (override via DISPATCH_GLOBAL_CONFIG) and deep-merge it underneath every project/working-directory dispatch.toml, so machine-wide settings — most notably globally available LSP servers — work in any repo without per-repo config. Local always wins on conflicts. - loader: add getGlobalConfigPath(), loadGlobalConfig(), mergeConfigs(); loadConfig(dir) now loads+merges global. [lsp] and [[keys]] merge by id; [permissions] merge per-group with global patterns emitted first so local rules win at evaluation time (findLast). A malformed global config is downgraded to empty rather than breaking every repo. - watcher: watch BOTH global and local dispatch.toml so hot-reload re-merges on either change (dedupes when paths coincide). - export new loader fns from config/index and core index. - types/agent-manager: doc updates reflecting merged LSP resolution. - dispatch.toml: document global-default merge behavior; activate biome and typescript-language-server LSP entries. - tests: merge precedence, lsp/keys merge-by-id, permissions merge, filesystem integration, malformed-global resilience; isolate global path in existing loader tests. --- packages/api/src/agent-manager.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'packages/api/src') diff --git a/packages/api/src/agent-manager.ts b/packages/api/src/agent-manager.ts index 7cfa03c..913fb15 100644 --- a/packages/api/src/agent-manager.ts +++ b/packages/api/src/agent-manager.ts @@ -390,11 +390,14 @@ export class AgentManager { /** * Resolve (and cache) the LSP servers configured for a working directory. * - * LSP config is project-scoped: it lives in the `dispatch.toml` of the - * tab's effective working directory, NOT the global config. We read that - * directory's config once and cache the resolved servers; the cache is - * cleared on config hot-reload. Returns `[]` when the directory has no - * `[lsp]` block (the common case). + * LSP config is resolved by `loadConfig`, which merges the HOME-directory + * global `dispatch.toml` (`~/.config/dispatch/dispatch.toml`) underneath the + * tab's effective working-directory `dispatch.toml` — local `[lsp.]` + * entries override global ones sharing the same id, while global-only + * servers stay active in every repository. We read+merge that config once + * per directory and cache the resolved servers; the cache is cleared on + * config hot-reload. Returns `[]` when neither config declares an `[lsp]` + * block (the common case). */ private getLspServersForDir(dir: string): ResolvedLspServer[] { const cached = this.lspServersByDir.get(dir); -- cgit v1.2.3