fix(bmad-module): copy file-typed agents/commands entries on install

The copy planner treated every skills/agents/commands entry as a
directory and ran it through addDirRecursive, which lists files *under*
the path. For a subagent declared as a file (e.g.
`"agents": ["./agents/foo.md"]` — a standard Claude-Code shape) that
listed nothing, so the agent was silently dropped from the install even
though rewriteManifestPaths already remapped it to `./agents/foo.md`.

Stat each entry and branch: directories recurse as before, files are
queued directly (honoring the ignore matcher). Verified by the
comprehensive fixture's changelog-archivist.md agent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
pbean 2026-05-28 19:29:40 -07:00
parent 354b252abd
commit dfae0291ca
1 changed files with 12 additions and 2 deletions

View File

@ -248,8 +248,18 @@ export async function buildCopyPlan(sourceDir, manifest, ignoreMatch) {
const srcRel = stripDotSlash(declared); const srcRel = stripDotSlash(declared);
if (!srcRel) continue; if (!srcRel) continue;
const destRel = `${destPrefix}/${path.posix.basename(srcRel)}`; const destRel = `${destPrefix}/${path.posix.basename(srcRel)}`;
await addDirRecursive(srcRel, destRel); // Entries may be directories (skills, agent packs) or single files
if (destPrefix === 'skills') skillDestDirs.push(destRel); // (e.g. a subagent declared as `./agents/foo.md`). Stat to branch;
// rewriteManifestPaths() remaps both to `<destPrefix>/<basename>`.
try {
const stat = await fs.stat(path.join(sourceDir, srcRel));
if (stat.isDirectory()) {
await addDirRecursive(srcRel, destRel);
if (destPrefix === 'skills') skillDestDirs.push(destRel);
} else if (stat.isFile() && (!ignoreMatch || !ignoreMatch(srcRel))) addFile(srcRel, destRel);
} catch {
/* missing — validateDeclaredPaths surfaces declared misses */
}
} }
} }