ma-agents 3.4.4 → 3.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bmad.js +61 -7
- package/package.json +1 -1
package/lib/bmad.js
CHANGED
|
@@ -3,6 +3,7 @@ const path = require('path');
|
|
|
3
3
|
const os = require('os');
|
|
4
4
|
const { execSync } = require('child_process');
|
|
5
5
|
const chalk = require('chalk');
|
|
6
|
+
const yaml = require('yaml');
|
|
6
7
|
|
|
7
8
|
const BMAD_DIR = '_bmad';
|
|
8
9
|
const CONFIG_DIR = path.join(BMAD_DIR, '_config', 'agents');
|
|
@@ -206,22 +207,75 @@ async function updateBmad(modules = ['bmm', 'bmb'], tools = [], projectRoot = pr
|
|
|
206
207
|
// the files-manifest, finds module "custom", and fails because it can't locate
|
|
207
208
|
// the source for a module named "custom". Fix: strip stale "custom" module
|
|
208
209
|
// entries from the manifest so the module gets cleanly reinstalled via --custom-content.
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
// bmad-method 6.2.2 bug: on --action update --yes, the installer reads
|
|
211
|
+
// manifest.yaml to discover previously installed modules, then preserves them
|
|
212
|
+
// all (non-interactive default). It then tries to reinstall each one.
|
|
213
|
+
// "custom" fails because there's no source under that name (it's "ma-skills"),
|
|
214
|
+
// and "bmb" fails due to a broken directory structure in 6.2.2.
|
|
215
|
+
//
|
|
216
|
+
// Fix: before running bmad-method, clean all three persistence layers:
|
|
217
|
+
// 1. manifest.yaml — remove stale module entries
|
|
218
|
+
// 2. files-manifest.csv — remove stale file tracking entries
|
|
219
|
+
// 3. physical directories — remove _bmad/bmb/ and _bmad/_config/custom/
|
|
220
|
+
|
|
221
|
+
const staleModules = ['custom', 'bmb'];
|
|
222
|
+
|
|
223
|
+
// 1. Clean manifest.yaml (the primary trigger for the re-install loop)
|
|
224
|
+
const yamlManifestPath = path.join(projectRoot, BMAD_DIR, '_config', 'manifest.yaml');
|
|
225
|
+
if (fs.existsSync(yamlManifestPath)) {
|
|
211
226
|
try {
|
|
212
|
-
|
|
227
|
+
const yamlContent = await fs.readFile(yamlManifestPath, 'utf-8');
|
|
228
|
+
const manifest = yaml.parse(yamlContent);
|
|
229
|
+
if (manifest?.modules && Array.isArray(manifest.modules)) {
|
|
230
|
+
const before = manifest.modules.length;
|
|
231
|
+
manifest.modules = manifest.modules.filter(
|
|
232
|
+
m => !staleModules.includes(typeof m === 'string' ? m : m.name)
|
|
233
|
+
);
|
|
234
|
+
const removed = before - manifest.modules.length;
|
|
235
|
+
if (removed > 0) {
|
|
236
|
+
await fs.writeFile(yamlManifestPath, yaml.stringify(manifest), 'utf-8');
|
|
237
|
+
console.log(chalk.gray(` Cleaned ${removed} stale module(s) from manifest.yaml`));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
} catch (err) {
|
|
241
|
+
// Non-fatal
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 2. Clean files-manifest.csv (prevents stale file-tracking references)
|
|
246
|
+
const filesManifestPath = path.join(projectRoot, BMAD_DIR, '_config', 'files-manifest.csv');
|
|
247
|
+
if (fs.existsSync(filesManifestPath)) {
|
|
248
|
+
try {
|
|
249
|
+
let csv = await fs.readFile(filesManifestPath, 'utf-8');
|
|
213
250
|
const before = csv.split('\n').length;
|
|
214
251
|
csv = csv.split('\n').filter(line => {
|
|
215
252
|
const fields = line.split(',');
|
|
216
|
-
|
|
253
|
+
const mod = fields[2] && fields[2].replace(/"/g, '');
|
|
254
|
+
return !staleModules.includes(mod);
|
|
217
255
|
}).join('\n');
|
|
218
256
|
const after = csv.split('\n').length;
|
|
219
257
|
if (after < before) {
|
|
220
|
-
await fs.writeFile(
|
|
221
|
-
console.log(chalk.gray(` Cleaned ${before - after} stale
|
|
258
|
+
await fs.writeFile(filesManifestPath, csv, 'utf-8');
|
|
259
|
+
console.log(chalk.gray(` Cleaned ${before - after} stale entries from files-manifest.csv`));
|
|
222
260
|
}
|
|
223
261
|
} catch (err) {
|
|
224
|
-
// Non-fatal
|
|
262
|
+
// Non-fatal
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// 3. Remove physical directories so bmad-method doesn't re-discover them
|
|
267
|
+
const staleDirs = [
|
|
268
|
+
path.join(projectRoot, BMAD_DIR, 'bmb'),
|
|
269
|
+
path.join(projectRoot, BMAD_DIR, '_config', 'custom'),
|
|
270
|
+
];
|
|
271
|
+
for (const dir of staleDirs) {
|
|
272
|
+
if (fs.existsSync(dir)) {
|
|
273
|
+
try {
|
|
274
|
+
await fs.remove(dir);
|
|
275
|
+
console.log(chalk.gray(` Removed stale directory: ${path.relative(projectRoot, dir)}`));
|
|
276
|
+
} catch (err) {
|
|
277
|
+
// Non-fatal
|
|
278
|
+
}
|
|
225
279
|
}
|
|
226
280
|
}
|
|
227
281
|
|