Skip to content

CSV split(',') in installer misreads quoted fields from agent-manifest.csv #2141

@alexeyv

Description

@alexeyv

Summary

The installer parses agent-manifest.csv using line.split(','), which does not handle RFC 4180 quoted CSV fields. Fields like capabilities and principles contain commas within double-quoted values, causing the naive comma-split to produce too many columns and shift all subsequent column indices.

Impact

cols[10] is intended to read the module column but instead picks up a fragment from a different field. This produces incorrect agent-command values in the merged bmad-help.csv.

For example, the analyst row generates:

bmad:competitive analysis:agent:analyst

instead of the correct:

bmad:bmm:agent:analyst

Location

tools/installer/core/installer.js — the enrichAgentInfo method, around the line:

const cols = line.split(',');

Suggested Fix

Replace the naive line.split(',') with a proper CSV field parser that respects double-quoted fields (RFC 4180). A minimal approach:

function parseCSVLine(line) {
  const fields = [];
  let current = '';
  let inQuotes = false;
  for (let i = 0; i < line.length; i++) {
    const ch = line[i];
    if (inQuotes) {
      if (ch === '"' && line[i + 1] === '"') { current += '"'; i++; }
      else if (ch === '"') { inQuotes = false; }
      else { current += ch; }
    } else {
      if (ch === '"') { inQuotes = true; }
      else if (ch === ',') { fields.push(current); current = ''; }
      else { current += ch; }
    }
  }
  fields.push(current);
  return fields;
}

Additionally, cols[10] should likely be cols[9] — the module column is at index 9 in the header (name,displayName,title,icon,capabilities,role,identity,communicationStyle,principles,module,path,canonicalId).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions