From 62418b4010d2781fd51845d02d07d11e46f4b8c2 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sun, 28 Jun 2026 23:07:52 +0200 Subject: [PATCH] feat(env): wire supporter-binary resolution at boot (T-495) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main resolves the override map (and first-run auto-detects, using the primed login-shell PATH) right after bootSettings.load(), exposing the process-wide activeSupporterBinaries that tool consumers read — the d2 template (T-494) will resolve its binary through it. Analyze clean. Co-Authored-By: Claude Opus 4.8 (1M context) --- lib/main.dart | 8 ++++++++ lib/src/env/supporter_binaries.dart | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index 2496bf5f..c4f72141 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -58,6 +58,7 @@ import 'package:clide/src/editor/registry.dart' show EditorRegistry; import 'package:clide/src/git/client.dart'; import 'package:clide/src/cli/argv_dispatch.dart'; import 'package:clide/src/env/shell_env.dart' show primeLoginShellPath; +import 'package:clide/src/env/supporter_binaries.dart'; import 'package:clide/src/ipc/envelope.dart'; import 'package:clide/src/ipc/mcp_server.dart'; import 'package:clide/src/ipc/paths.dart' show workspaceSocketPath, logDirectory; @@ -114,6 +115,13 @@ Future main() async { await primeLoginShellPath(); final bootSettings = SettingsStore(appDir: appDir); await bootSettings.load(); + // Resolve external supporter binaries (claude, d2, …) — explicit user-scope + // overrides first, else the primed PATH + the well-known dirs; auto-detect + // and pin them on first run (T-495, D-104). + activeSupporterBinaries = await loadSupporterBinaries( + readOverrides: () => bootSettings.get(supporterToolsKey), + writeOverrides: (m) => bootSettings.set(supporterToolsKey, m), + ); startupWorkRoot = resolveStartupWorkspace( cwdRoot: startupWorkRoot, lastProject: bootSettings.get('app.lastProject'), diff --git a/lib/src/env/supporter_binaries.dart b/lib/src/env/supporter_binaries.dart index cfd44cc1..a1755df9 100644 --- a/lib/src/env/supporter_binaries.dart +++ b/lib/src/env/supporter_binaries.dart @@ -92,6 +92,11 @@ class SupporterBinaries { bool _fileExists(String p) => File(p).existsSync(); +/// The process-wide resolver, wired at boot via [loadSupporterBinaries]. Tool +/// consumers (e.g. the d2 template, T-494) read it to resolve a binary; null in +/// headless contexts where boot wiring hasn't run. +SupporterBinaries? activeSupporterBinaries; + /// The user-scope SettingsStore key (app layer, `~/.clide`, per-machine) holding /// the tool→absolute-path override map. const supporterToolsKey = 'app.tools';