MCPcopy
hub / github.com/Fission-AI/OpenSpec / runInteractiveSelector

Method runInteractiveSelector

src/commands/validate.ts:80–108  ·  view source on GitHub ↗
(root: ResolvedOpenSpecRoot, opts: { strict: boolean; json: boolean; concurrency?: string })

Source from the content-addressed store, hash-verified

78 }
79
80 private async runInteractiveSelector(root: ResolvedOpenSpecRoot, opts: { strict: boolean; json: boolean; concurrency?: string }): Promise<void> {
81 const { select } = await import('@inquirer/prompts');
82 const choice = await select({
83 message: 'What would you like to validate?',
84 choices: [
85 { name: 'All (changes + specs)', value: 'all' },
86 { name: 'All changes', value: 'changes' },
87 { name: 'All specs', value: 'specs' },
88 { name: 'Pick a specific change or spec', value: 'one' },
89 ],
90 });
91
92 if (choice === 'all') return this.runBulkValidation(root, { changes: true, specs: true }, opts);
93 if (choice === 'changes') return this.runBulkValidation(root, { changes: true, specs: false }, opts);
94 if (choice === 'specs') return this.runBulkValidation(root, { changes: false, specs: true }, opts);
95
96 // one
97 const [changes, specs] = await Promise.all([getActiveChangeIds(root.path), getSpecIds(root.path)]);
98 const items: { name: string; value: { type: ItemType; id: string } }[] = [];
99 items.push(...changes.map(id => ({ name: `change/${id}`, value: { type: 'change' as const, id } })));
100 items.push(...specs.map(id => ({ name: `spec/${id}`, value: { type: 'spec' as const, id } })));
101 if (items.length === 0) {
102 console.error('No items found to validate.');
103 process.exitCode = 1;
104 return;
105 }
106 const picked = await select<{ type: ItemType; id: string }>({ message: 'Pick an item', choices: items });
107 await this.validateByType(root, picked.type, picked.id, opts);
108 }
109
110 private printNonInteractiveHint(root: ResolvedOpenSpecRoot): void {
111 console.error('Nothing to validate. Try one of:');

Callers 1

executeMethod · 0.95

Calls 4

runBulkValidationMethod · 0.95
validateByTypeMethod · 0.95
getActiveChangeIdsFunction · 0.85
getSpecIdsFunction · 0.85

Tested by

no test coverage detected