{"record":{"id":"9072351bedada2dd","repo":"jackwener/OpenCLI","slug":"unknown-mode-mode","errorCode":null,"errorMessage":"unknown mode \"${mode}\"","messagePattern":"unknown mode \"(.+?)\"","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/kimi/audit-extras.js","lineNumber":158,"sourceCode":"        { name: 'mode', required: false, help: 'Navigate to mode first: ppt|docs|deep-research|agent|websites|sheets|agent-swarm|code' },\n        { name: 'limit', type: 'int', required: false, default: 30 },\n    ],\n    columns: AUDIT_EXTRA_COLUMNS,\n    func: async (page, kwargs) => {\n        const mode = String(kwargs?.mode || '').trim().toLowerCase();\n        const modeMap = {\n            ppt: '/slides',\n            docs: '/docs',\n            'deep-research': '/deep-research',\n            agent: '/agent',\n            websites: '/websites',\n            sheets: '/sheets',\n            'agent-swarm': '/agent-swarm',\n            code: '/code',\n        };\n        if (mode) {\n            const target = modeMap[mode];\n            if (!target) throw new ArgumentError('mode', `unknown mode \"${mode}\"`);\n            await page.goto(`${KIMI_URL}${target.slice(1)}`);\n            await page.wait(2);\n        } else {\n            await ensureOnKimi(page);\n        }\n        // Templates: visible <a> or [role=button] whose text follows the\n        // pattern \"category\\n\\ntitle\" (e.g., \"商业财经\\n\\n宁德时代财报分析\").\n        const cards = await page.evaluate(`(() => {\n      ${IS_VISIBLE_JS}\n      const els = Array.from(document.querySelectorAll('a, [role=\"button\"], button')).filter(isVisible);\n      const out = [];\n      for (const el of els) {\n        const tx = (el.innerText || '').trim();\n        // Match \"category\\\\n\\\\ntitle\" or \"category\\\\ntitle\" patterns\n        const m = tx.match(/^([^\\\\n]+)\\\\n+(.+)$/);\n        if (m && m[1].length < 30 && m[2].length < 100 && m[1] !== m[2]) {\n          out.push({ category: m[1].trim(), title: m[2].trim() });\n        }","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/audit-extras.js#L140-L176","documentation":"The kimi templates command accepts a --mode flag that must be one of a fixed set (ppt, docs, deep-research, agent, websites, sheets, agent-swarm, code). If a mode string is provided but is not a key in modeMap, the command throws ArgumentError('mode', `unknown mode \"${mode}\"`).","triggerScenarios":"Running `kimi templates --mode slide` or `--mode PPT-` or any typo/unsupported value; passing an alias not in the map (e.g. 'presentation' instead of 'ppt'); uppercase input is lowercased first, so case is not the issue — the spelling must match exactly.","commonSituations":"Guessing mode names from the product UI instead of the help text; using 'chat' or 'search' which are not template-bearing pages; scripts built against an older CLI whose mode list lacked newer entries like 'code' or 'agent-swarm'.","solutions":["Use one of the exact supported modes: ppt|docs|deep-research|agent|websites|sheets|agent-swarm|code","Run `kimi templates --help` (or read the command args) to see the current mode list","Omit --mode entirely to list templates on the currently open page instead of navigating","Check for typos/aliases: 'slides' is not a mode — the mode is 'ppt'"],"exampleFix":"// before\nawait runCli('kimi templates', { mode: 'slides' });\n// after\nawait runCli('kimi templates', { mode: 'ppt' }); // or omit mode\n","handlingStrategy":"validation","validationCode":"const VALID_MODES = ['ppt','docs','deep-research','agent','websites','sheets','agent-swarm','code'];\nif (mode && !VALID_MODES.includes(String(mode).trim().toLowerCase())) throw new Error(`mode must be one of: ${VALID_MODES.join(', ')}`);","typeGuard":"function isValidMode(m) { return ['ppt','docs','deep-research','agent','websites','sheets','agent-swarm','code'].includes(String(m).trim().toLowerCase()); }","tryCatchPattern":"try {\n  await runCli('kimi templates', { mode });\n} catch (e) {\n  if (e.name === 'ArgumentError' && /unknown mode/.test(e.message)) console.error(`Bad --mode '${mode}'. Use: ppt|docs|deep-research|agent|websites|sheets|agent-swarm|code`);\n  else throw e;\n}","preventionTips":["Validate --mode against the documented list before invoking","Remember 'slides' is not valid — the mode is 'ppt'","Check --help for newly added modes when upgrading the CLI","Omit --mode when you want the currently open page scanned"],"tags":["argument-validation","cli","user-input"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}