33 applyAgentConfigurations ,
44 prepareAgentConfigurations ,
55} from '../../agent/configurator' ;
6+ import { detectAgentsOnPath } from '../../agent/availability' ;
67import {
78 AGENT_IDS ,
89 type AgentId ,
@@ -44,6 +45,7 @@ const AGENT_LABELS: Record<AgentId, string> = {
4445 hermes : 'Hermes Agent' ,
4546 pi : 'Pi' ,
4647} ;
48+ const DEFAULT_INTERACTIVE_AGENTS : AgentId [ ] = [ 'claude-code' , 'codex' ] ;
4749
4850function uniqueAgents ( values : string [ ] ) : AgentId [ ] {
4951 const result : AgentId [ ] = [ ] ;
@@ -69,11 +71,17 @@ function isInteractiveInvocation(flags: GlobalFlags): boolean {
6971
7072async function interactiveOptions (
7173 config : Config ,
74+ detectedAgents : Set < AgentId > ,
7275) : Promise < AgentSetupOptions > {
7376 const selectedAgents = await promptMultiSelect ( {
7477 message : 'Select agents to configure' ,
75- choices : AGENT_IDS . map ( ( agent ) => ( { value : agent , label : AGENT_LABELS [ agent ] } ) ) ,
76- initialValues : [ 'claude-code' , 'codex' ] ,
78+ choices : AGENT_IDS . map ( ( agent ) => ( {
79+ value : agent ,
80+ label : detectedAgents . has ( agent )
81+ ? AGENT_LABELS [ agent ]
82+ : `${ AGENT_LABELS [ agent ] } (not detected on PATH)` ,
83+ } ) ) ,
84+ initialValues : DEFAULT_INTERACTIVE_AGENTS . filter ( ( agent ) => detectedAgents . has ( agent ) ) ,
7785 required : true ,
7886 } ) ;
7987 if ( ! selectedAgents ?. length ) {
@@ -105,9 +113,13 @@ async function interactiveOptions(
105113 }
106114 if ( ! apiKey ) throw new CLIError ( 'An API key is required.' , ExitCode . USAGE ) ;
107115
108- const confirmed = await promptConfirm ( {
109- message : `Configure ${ agents . map ( ( agent ) => AGENT_LABELS [ agent ] ) . join ( ', ' ) } ?` ,
110- } ) ;
116+ const notDetected = agents . filter ( ( agent ) => ! detectedAgents . has ( agent ) ) ;
117+ let message = `Configure ${ agents . map ( ( agent ) => AGENT_LABELS [ agent ] ) . join ( ', ' ) } ? `
118+ + 'mmx will only write configuration files; it will not install or launch agents.' ;
119+ if ( notDetected . length > 0 ) {
120+ message += ` Not detected on PATH: ${ notDetected . map ( ( agent ) => AGENT_LABELS [ agent ] ) . join ( ', ' ) } .` ;
121+ }
122+ const confirmed = await promptConfirm ( { message } ) ;
111123 if ( ! confirmed ) throw new CLIError ( 'Agent setup cancelled.' , ExitCode . GENERAL ) ;
112124
113125 return { agents, apiKey, region : selectedRegion , model : 'MiniMax-M3' } ;
@@ -166,7 +178,7 @@ function nonInteractiveOptions(
166178
167179export default defineCommand ( {
168180 name : 'agent setup' ,
169- description : 'Configure MiniMax for external coding agents' ,
181+ description : 'Configure external coding agents (does not install or launch them) ' ,
170182 usage : 'mmx agent setup [--agent <name> ... | --all] [--api-key <key>] [--region <region>]' ,
171183 options : [
172184 {
@@ -185,8 +197,9 @@ export default defineCommand({
185197 'mmx agent setup --agent opencode --api-key <key> --region cn --dry-run' ,
186198 ] ,
187199 async run ( config : Config , flags : GlobalFlags ) {
200+ const detectedAgents = detectAgentsOnPath ( ) ;
188201 const options = isInteractiveInvocation ( flags )
189- ? await interactiveOptions ( config )
202+ ? await interactiveOptions ( config , detectedAgents )
190203 : nonInteractiveOptions ( config , flags ) ;
191204
192205 let verification : AgentVerification = {
@@ -212,5 +225,12 @@ export default defineCommand({
212225 agents : options . agents ,
213226 files,
214227 } , format ) ) ;
228+ const notDetected = options . agents . filter ( ( agent ) => ! detectedAgents . has ( agent ) ) ;
229+ if ( notDetected . length > 0 && ! config . quiet ) {
230+ process . stderr . write (
231+ `Warning: Not detected on PATH: ${ notDetected . map ( ( agent ) => AGENT_LABELS [ agent ] ) . join ( ', ' ) } . `
232+ + 'mmx only manages configuration; it does not install or launch agents.\n' ,
233+ ) ;
234+ }
215235 } ,
216236} ) ;
0 commit comments