MCPcopy Index your code
hub / github.com/Fission-AI/OpenSpec / getSelectedTools

Method getSelectedTools

src/core/init.ts:284–381  ·  view source on GitHub ↗
(
    toolStates: Map<string, ToolSkillStatus>,
    extendMode: boolean,
    detectedTools: AIToolOption[],
    projectPath: string
  )

Source from the content-addressed store, hash-verified

282 // ═══════════════════════════════════════════════════════════
283
284 private async getSelectedTools(
285 toolStates: Map<string, ToolSkillStatus>,
286 extendMode: boolean,
287 detectedTools: AIToolOption[],
288 projectPath: string
289 ): Promise<string[]> {
290 // Check for --tools flag first
291 const nonInteractiveSelection = this.resolveToolsArg();
292 if (nonInteractiveSelection !== null) {
293 return nonInteractiveSelection;
294 }
295
296 const validTools = getToolsWithSkillsDir();
297 const detectedToolIds = new Set(detectedTools.map((t) => t.value));
298 const configuredToolIds = new Set(
299 [...toolStates.entries()]
300 .filter(([, status]) => status.configured)
301 .map(([toolId]) => toolId)
302 );
303 const shouldPreselectDetected = !extendMode && configuredToolIds.size === 0;
304 const canPrompt = this.canPromptInteractively();
305
306 // Non-interactive mode: use detected tools as fallback (task 7.8)
307 if (!canPrompt) {
308 if (detectedToolIds.size > 0) {
309 return [...detectedToolIds];
310 }
311 throw new Error(
312 `No tools detected and no --tools flag provided. Valid tools:\n ${validTools.join('\n ')}\n\nUse --tools all, --tools none, or --tools claude,cursor,...`
313 );
314 }
315
316 if (validTools.length === 0) {
317 throw new Error(
318 `No tools available for skill generation.`
319 );
320 }
321
322 // Interactive mode: show searchable multi-select
323 const { searchableMultiSelect } = await import('../prompts/searchable-multi-select.js');
324
325 // Build choices: pre-select configured tools; keep detected tools visible but unselected.
326 const sortedChoices = validTools
327 .map((toolId) => {
328 const tool = AI_TOOLS.find((t) => t.value === toolId);
329 const status = toolStates.get(toolId);
330 const configured = status?.configured ?? false;
331 const detected = detectedToolIds.has(toolId);
332
333 return {
334 name: tool?.name || toolId,
335 value: toolId,
336 configured,
337 detected: detected && !configured,
338 preSelected: configured || (shouldPreselectDetected && detected && !configured),
339 };
340 })
341 .sort((a, b) => {

Callers 1

executeMethod · 0.95

Calls 6

resolveToolsArgMethod · 0.95
getToolsWithSkillsDirFunction · 0.85
searchableMultiSelectFunction · 0.85
getMethod · 0.80
hasMethod · 0.80

Tested by

no test coverage detected