From 8877e010835eb9525f234bd9f44d06d9cd7791e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=82CHES?= Date: Tue, 17 Mar 2026 17:05:54 -0600 Subject: [PATCH] refactor: add domain-grouped re-exports for preferences module (#996) Co-authored-by: Claude Opus 4.6 (1M context) --- .../extensions/gsd/preferences-hooks.ts | 10 +++++++++ .../extensions/gsd/preferences-models.ts | 22 +++++++++++++++++++ .../extensions/gsd/preferences-skills.ts | 18 +++++++++++++++ src/resources/extensions/gsd/preferences.ts | 7 ++++++ 4 files changed, 57 insertions(+) create mode 100644 src/resources/extensions/gsd/preferences-hooks.ts create mode 100644 src/resources/extensions/gsd/preferences-models.ts create mode 100644 src/resources/extensions/gsd/preferences-skills.ts diff --git a/src/resources/extensions/gsd/preferences-hooks.ts b/src/resources/extensions/gsd/preferences-hooks.ts new file mode 100644 index 000000000..ed99d5c29 --- /dev/null +++ b/src/resources/extensions/gsd/preferences-hooks.ts @@ -0,0 +1,10 @@ +/** + * Focused re-export: hook-related preferences. + * + * Consumers that only need hook resolution can import from this module + * instead of the monolithic preferences.ts, reducing coupling surface. + */ +export { + resolvePostUnitHooks, + resolvePreDispatchHooks, +} from "./preferences.js"; diff --git a/src/resources/extensions/gsd/preferences-models.ts b/src/resources/extensions/gsd/preferences-models.ts new file mode 100644 index 000000000..072556548 --- /dev/null +++ b/src/resources/extensions/gsd/preferences-models.ts @@ -0,0 +1,22 @@ +/** + * Focused re-export: model-related preferences. + * + * Consumers that only need model resolution can import from this module + * instead of the monolithic preferences.ts, reducing coupling surface. + */ +export { + // Types + type GSDPhaseModelConfig, + type GSDModelConfig, + type GSDModelConfigV2, + type ResolvedModelConfig, + + // Functions + resolveModelForUnit, + resolveModelWithFallbacksForUnit, + resolveDynamicRoutingConfig, + getNextFallbackModel, + isTransientNetworkError, + validateModelId, + updatePreferencesModels, +} from "./preferences.js"; diff --git a/src/resources/extensions/gsd/preferences-skills.ts b/src/resources/extensions/gsd/preferences-skills.ts new file mode 100644 index 000000000..5737cd73a --- /dev/null +++ b/src/resources/extensions/gsd/preferences-skills.ts @@ -0,0 +1,18 @@ +/** + * Focused re-export: skill-related preferences. + * + * Consumers that only need skill resolution can import from this module + * instead of the monolithic preferences.ts, reducing coupling surface. + */ +export { + // Types + type GSDSkillRule, + type SkillDiscoveryMode, + type SkillResolution, + type SkillResolutionReport, + + // Functions + resolveAllSkillReferences, + resolveSkillDiscoveryMode, + resolveSkillStalenessDays, +} from "./preferences.js"; diff --git a/src/resources/extensions/gsd/preferences.ts b/src/resources/extensions/gsd/preferences.ts index a16819684..83faf0d53 100644 --- a/src/resources/extensions/gsd/preferences.ts +++ b/src/resources/extensions/gsd/preferences.ts @@ -261,6 +261,7 @@ export function loadEffectiveGSDPreferences(): LoadedGSDPreferences | null { } // ─── Skill Reference Resolution ─────────────────────────────────────────────── +// Focused re-exports available via ./preferences-skills.js export interface SkillResolution { /** The original reference from preferences (bare name or path). */ @@ -547,6 +548,9 @@ export function getIsolationMode(): "none" | "worktree" | "branch" { return "worktree"; // default } +// ─── Model Resolution ───────────────────────────────────────────────────────── +// Focused re-exports available via ./preferences-models.js + /** * Resolve which model ID to use for a given auto-mode unit type. * Returns undefined if no model preference is set for this unit type. @@ -1389,6 +1393,9 @@ function mergePostUnitHooks( return merged.length > 0 ? merged : undefined; } +// ─── Hook Resolution ────────────────────────────────────────────────────────── +// Focused re-exports available via ./preferences-hooks.js + /** * Resolve enabled post-unit hooks from effective preferences. * Returns an empty array when no hooks are configured.