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

Function removeKiroHooks

src/core/uninstall.ts:453–488  ·  view source on GitHub ↗

* Kiro: hooks/*.kiro.hook files matching comet patterns.

(
  platformBase: string,
  scriptRelPaths: string[],
)

Source from the content-addressed store, hash-verified

451 * Kiro: hooks/*.kiro.hook files matching comet patterns.
452 */
453async function removeKiroHooks(
454 platformBase: string,
455 scriptRelPaths: string[],
456): Promise<RemovalResult> {
457 const hooksDir = path.join(platformBase, 'hooks');
458 if (!(await fileExists(hooksDir))) {
459 return { removed: 0, failed: 0 };
460 }
461
462 let removed = 0;
463 const entries = await readDir(hooksDir);
464
465 for (const entry of entries) {
466 if (!entry.endsWith('.kiro.hook')) continue;
467 // Match files that correspond to comet scripts
468 const baseName = entry.replace('.kiro.hook', '');
469 const isCometHook = scriptRelPaths.some((scriptPath) => {
470 const scriptBase = path.basename(scriptPath).replace('.sh', '');
471 return scriptBase === baseName;
472 });
473
474 if (isCometHook) {
475 const hookPath = path.join(hooksDir, entry);
476 if (await removeFile(hookPath)) {
477 removed++;
478 }
479 }
480 }
481
482 // Clean up empty hooks directory
483 if (await isDirEmpty(hooksDir)) {
484 await removeDir(hooksDir);
485 }
486
487 return { removed, failed: 0 };
488}
489
490/**
491 * Remove Comet working directories from a project.

Callers 1

Calls 5

readDirFunction · 0.85
removeFileFunction · 0.85
isDirEmptyFunction · 0.85
removeDirFunction · 0.85
fileExistsFunction · 0.50

Tested by

no test coverage detected