mirror of
https://github.com/bmadcode/BMAD-METHOD.git
synced 2025-12-17 09:45:25 +00:00
fix: normalize workflow manifest schema (#1071)
* fix: normalize workflow manifest schema * fix: escape workflow manifest values safely --------- Co-authored-by: Brian <bmadcode@gmail.com>
This commit is contained in:
parent
3bc485d0ed
commit
ed0defbe08
@ -581,6 +581,11 @@ class ManifestGenerator {
|
|||||||
*/
|
*/
|
||||||
async writeWorkflowManifest(cfgDir) {
|
async writeWorkflowManifest(cfgDir) {
|
||||||
const csvPath = path.join(cfgDir, 'workflow-manifest.csv');
|
const csvPath = path.join(cfgDir, 'workflow-manifest.csv');
|
||||||
|
const escapeCsv = (value) => `"${String(value ?? '').replaceAll('"', '""')}"`;
|
||||||
|
const parseCsvLine = (line) => {
|
||||||
|
const columns = line.match(/(".*?"|[^",\s]+)(?=\s*,|\s*$)/g) || [];
|
||||||
|
return columns.map((c) => c.replaceAll(/^"|"$/g, ''));
|
||||||
|
};
|
||||||
|
|
||||||
// Read existing manifest to preserve entries
|
// Read existing manifest to preserve entries
|
||||||
const existingEntries = new Map();
|
const existingEntries = new Map();
|
||||||
@ -592,18 +597,21 @@ class ManifestGenerator {
|
|||||||
for (let i = 1; i < lines.length; i++) {
|
for (let i = 1; i < lines.length; i++) {
|
||||||
const line = lines[i];
|
const line = lines[i];
|
||||||
if (line) {
|
if (line) {
|
||||||
// Parse CSV (simple parsing assuming no commas in quoted fields)
|
const parts = parseCsvLine(line);
|
||||||
const parts = line.split('","');
|
|
||||||
if (parts.length >= 4) {
|
if (parts.length >= 4) {
|
||||||
const name = parts[0].replace(/^"/, '');
|
const [name, description, module, workflowPath] = parts;
|
||||||
const module = parts[2];
|
existingEntries.set(`${module}:${name}`, {
|
||||||
existingEntries.set(`${module}:${name}`, line);
|
name,
|
||||||
|
description,
|
||||||
|
module,
|
||||||
|
path: workflowPath,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create CSV header - removed standalone column as ALL workflows now generate commands
|
// Create CSV header - standalone column removed, everything is canonicalized to 4 columns
|
||||||
let csv = 'name,description,module,path\n';
|
let csv = 'name,description,module,path\n';
|
||||||
|
|
||||||
// Combine existing and new workflows
|
// Combine existing and new workflows
|
||||||
@ -617,12 +625,18 @@ class ManifestGenerator {
|
|||||||
// Add/update new workflows
|
// Add/update new workflows
|
||||||
for (const workflow of this.workflows) {
|
for (const workflow of this.workflows) {
|
||||||
const key = `${workflow.module}:${workflow.name}`;
|
const key = `${workflow.module}:${workflow.name}`;
|
||||||
allWorkflows.set(key, `"${workflow.name}","${workflow.description}","${workflow.module}","${workflow.path}"`);
|
allWorkflows.set(key, {
|
||||||
|
name: workflow.name,
|
||||||
|
description: workflow.description,
|
||||||
|
module: workflow.module,
|
||||||
|
path: workflow.path,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write all workflows
|
// Write all workflows
|
||||||
for (const [, value] of allWorkflows) {
|
for (const [, value] of allWorkflows) {
|
||||||
csv += value + '\n';
|
const row = [escapeCsv(value.name), escapeCsv(value.description), escapeCsv(value.module), escapeCsv(value.path)].join(',');
|
||||||
|
csv += row + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
await fs.writeFile(csvPath, csv);
|
await fs.writeFile(csvPath, csv);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user