MCPcopy
hub / github.com/rpamis/comet / initCommand

Function initCommand

src/commands/init.ts:283–521  ·  view source on GitHub ↗
(targetPath: string, options: InitOptions = {})

Source from the content-addressed store, hash-verified

281}
282
283export async function initCommand(targetPath: string, options: InitOptions = {}): Promise<void> {
284 const projectPath = path.resolve(targetPath);
285 const log = options.json ? () => undefined : console.log;
286
287 log(`\n${COMET_BANNER}\n`);
288 if (!options.json) {
289 await printVersionInfo(log);
290 }
291
292 const language = await selectLanguage(options);
293 const lang = language.id;
294
295 log(` ${t(lang, 'settingUp')} ${projectPath}\n`);
296
297 const detected = await detectPlatforms(projectPath);
298 const scope = await selectScope(options, lang);
299
300 const selectedPlatformIds = await selectPlatforms(detected, options, lang);
301 if (selectedPlatformIds.length === 0) {
302 if (options.json) {
303 console.log(
304 JSON.stringify(
305 {
306 projectPath,
307 scope,
308 language: language.id,
309 selectedPlatforms: [],
310 results: [],
311 },
312 null,
313 2,
314 ),
315 );
316 return;
317 }
318 log(`\n ${t(lang, 'noPlatforms')}\n`);
319 return;
320 }
321
322 const selectedPlatforms = PLATFORMS.filter((p) => selectedPlatformIds.includes(p.id));
323 const baseDir = getBaseDir(scope, projectPath);
324
325 type PlatformPlan = ComponentPlan & {
326 platform: Platform;
327 hasOS: boolean;
328 hasSP: boolean;
329 hasCM: boolean;
330 };
331
332 const plans: PlatformPlan[] = [];
333
334 for (const platform of selectedPlatforms) {
335 const hasOS = await hasSkills(baseDir, platform, 'openspec', selectedPlatforms, scope);
336 const hasSP = await hasSkills(baseDir, platform, 'superpowers', selectedPlatforms, scope);
337 const hasCM = await hasSkills(baseDir, platform, 'comet', selectedPlatforms, scope);
338
339 let osAction = resolveAction(hasOS, options);
340 let spAction = resolveAction(hasSP, options);

Callers 2

init-e2e.test.tsFile · 0.85
index.tsFile · 0.85

Calls 15

logFunction · 0.85
printVersionInfoFunction · 0.85
selectLanguageFunction · 0.85
tFunction · 0.85
detectPlatformsFunction · 0.85
selectScopeFunction · 0.85
selectPlatformsFunction · 0.85
getBaseDirFunction · 0.85
hasSkillsFunction · 0.85
resolveActionFunction · 0.85
applyBulkOverwriteChoiceFunction · 0.85

Tested by

no test coverage detected