Awesome Reviewers

For security-sensitive filesystem and dependency-install flows, treat any path/ref derived from CLI input or manifests as untrusted: (1) parse/validate it, and (2) strictly contain it to the intended root before any filesystem mutation (copy/swap/delete). Also, keep security posture consistent across equivalent install mechanisms.

Apply these standards:

Minimal example (pattern):

import { safePathInsideRoot } from './fs-safe.mjs';

function rmManifestPath(bmadDir, manifestRelPath) {
  const abs = safePathInsideRoot(bmadDir, path.join(bmadDir, manifestRelPath));
  return fs.rm(abs, { force: true });
}

// Before swapping/copying an install target:
const safeTargetDir = safePathInsideRoot(bmadDir, targetDir);
await atomicSwapDir(safeTargetDir, stagedDir);