33 */
44
55import * as p from "@clack/prompts" ;
6- import { getAgentMetadata } from "../agents/metadata" ;
6+ import type { Platform } from "../adapters/types" ;
7+ import { detectInstalledAgents , getAgentMetadata } from "../agents/metadata" ;
78import { getConfig , setConfig } from "./manager" ;
89import type { GlobalConfig } from "./types" ;
9- import { SUPPORTED_AGENTS } from "./types" ;
1010
1111export async function checkAndMigrateConfig (
1212 silent : boolean = false ,
1313) : Promise < void > {
1414 try {
1515 const config = getConfig ( ) ;
16- const missing = findMissingConfigs ( config ) ;
16+ const platform = getPlatform ( ) ;
17+ const missing = findMissingConfigs ( config , platform ) ;
1718
1819 if ( missing . length === 0 ) {
1920 return ;
@@ -46,22 +47,18 @@ export async function checkAndMigrateConfig(
4647 }
4748}
4849
49- function findMissingConfigs ( config : GlobalConfig ) : string [ ] {
50- const missing : string [ ] = [ ] ;
51-
52- for ( const id of SUPPORTED_AGENTS ) {
53- if ( ! config . agents . includes ( id ) ) {
54- missing . push ( id ) ;
55- }
56- }
57-
58- return missing ;
50+ function findMissingConfigs (
51+ config : GlobalConfig ,
52+ platform : Platform ,
53+ ) : string [ ] {
54+ const installedAgents = detectInstalledAgents ( platform ) ;
55+ return installedAgents . filter ( ( id ) => ! config . agents . includes ( id ) ) ;
5956}
6057
6158export function hasNewConfigsAvailable ( ) : boolean {
6259 try {
6360 const config = getConfig ( ) ;
64- const missing = findMissingConfigs ( config ) ;
61+ const missing = findMissingConfigs ( config , getPlatform ( ) ) ;
6562 return missing . length > 0 ;
6663 } catch {
6764 return false ;
@@ -71,8 +68,18 @@ export function hasNewConfigsAvailable(): boolean {
7168export function getNewConfigsAvailable ( ) : string [ ] {
7269 try {
7370 const config = getConfig ( ) ;
74- return findMissingConfigs ( config ) ;
71+ return findMissingConfigs ( config , getPlatform ( ) ) ;
7572 } catch {
7673 return [ ] ;
7774 }
7875}
76+
77+ function getPlatform ( ) : Platform {
78+ if ( process . platform === "darwin" ) {
79+ return "macos" ;
80+ }
81+ if ( process . platform === "win32" ) {
82+ return "windows" ;
83+ }
84+ return "linux" ;
85+ }
0 commit comments