{"record":{"id":"bf2352a78eb16c06","repo":"affaan-m/ECC","slug":"invalid-mode-mode-allowed-modes-allowedmo","errorCode":null,"errorMessage":"Invalid mode \"${mode}\". Allowed modes: ${allowedModes.join(', ')}","messagePattern":"Invalid mode \"(.+?)\"\\. Allowed modes: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/agent-compress.js","lineNumber":174,"sourceCode":"}\n\nconst allowedModes = ['catalog', 'summary', 'full'];\n\n/**\n * Build a compressed catalog from a directory of agents.\n *\n * Modes:\n *  - 'catalog': name, description, tools, model only (~2-3k tokens for 27 agents)\n *  - 'summary': catalog + first paragraph summary (~4-5k tokens)\n *  - 'full':    no compression, full body included\n *\n * Returns { agents: [], stats: { totalAgents, originalBytes, compressedBytes, compressedTokenEstimate, mode } }\n */\nfunction buildAgentCatalog(agentsDir, options = {}) {\n  const mode = options.mode || 'catalog';\n\n  if (!allowedModes.includes(mode)) {\n    throw new Error(`Invalid mode \"${mode}\". Allowed modes: ${allowedModes.join(', ')}`);\n  }\n\n  const filter = options.filter || null;\n\n  let agents = loadAgents(agentsDir);\n\n  if (typeof filter === 'function') {\n    agents = agents.filter(filter);\n  }\n\n  const originalBytes = agents.reduce((sum, a) => sum + a.byteSize, 0);\n\n  let compressed;\n  if (mode === 'catalog') {\n    compressed = agents.map(compressToCatalog);\n  } else if (mode === 'summary') {\n    compressed = agents.map(compressToSummary);\n  } else {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/agent-compress.js#L156-L192","documentation":"buildAgentCatalog accepts only the modes 'catalog', 'summary', or 'full' (allowedModes). The mode controls compression level of the agent catalog output. Passing any other string throws immediately before any files are read, so mistakes fail fast.","triggerScenarios":"Calling buildAgentCatalog(dir, { mode: 'compressed' }) or { mode: 'Catalog' } (case-sensitive), or wiring a CLI flag/option string like 'c' or 'minified' straight into options.mode.","commonSituations":"Typo or wrong casing in a script that generates token-budgeted catalogs; passing a user-supplied CLI argument without mapping it to the enum; renaming modes in custom forks without updating callers.","solutions":["Use one of the exact strings: 'catalog', 'summary', or 'full' (default is 'catalog' when mode is omitted).","If the value comes from user input, map or validate it against allowedModes before calling.","Check casing — the comparison is case-sensitive, so 'Summary' must be 'summary'.","Omit the mode option entirely if you want the default catalog behavior."],"exampleFix":"// before\nbuildAgentCatalog('agents/', { mode: 'Catalog' });\n// after\nbuildAgentCatalog('agents/', { mode: 'catalog' });","handlingStrategy":"validation","validationCode":"const allowed = ['catalog', 'summary', 'full'];\nif (!allowed.includes(mode)) throw new Error(`mode must be one of ${allowed.join(', ')}`);","typeGuard":"const isCatalogMode = (m) => m === 'catalog' || m === 'summary' || m === 'full';","tryCatchPattern":"try { buildAgentCatalog(dir, { mode }); } catch (e) { if (e.message.startsWith('Invalid mode')) { console.error('Use catalog | summary | full'); } else throw e; }","preventionTips":["Map CLI flags to the mode enum explicitly instead of passing raw strings","Remember the comparison is case-sensitive","Omit mode for the default 'catalog' behavior"],"tags":["validation","enum","cli"],"backgroundTag":"invalid-enum-value","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}