{"record":{"id":"12f62fcabe76b927","repo":"jackwener/OpenCLI","slug":"unknown-mode-name-known-object-keys-modes","errorCode":null,"errorMessage":"unknown mode \"${name}\". Known: ${Object.keys(MODES).join(', ')}","messagePattern":"unknown mode \"(.+?)\"\\. Known: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/kimi/ui.js","lineNumber":58,"sourceCode":"    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'name', positional: true, required: false, help: 'Mode name (omit to list all)' },\n    ],\n    columns: UI_COLUMNS,\n    func: async (page, kwargs) => {\n        const name = String(kwargs?.name || '').trim().toLowerCase();\n        if (!name) {\n            return Object.entries(MODES).map(([m, url]) => ({\n                Mode: m,\n                Status: 'available',\n                Url: KIMI_URL + url.slice(1),\n            }));\n        }\n        const target = MODES[name];\n        if (!target) {\n            throw new ArgumentError('name', `unknown mode \"${name}\". Known: ${Object.keys(MODES).join(', ')}`);\n        }\n        await ensureOnKimi(page);\n        await page.goto(`${KIMI_URL}${target.slice(1)}`);\n        await page.wait(1);\n        const url = await page.evaluate('window.location.href');\n        return [{ Mode: name, Status: 'navigated', Url: String(url || '') }];\n    },\n});\n\n// -------- sidebar-toggle --------\ncli({\n    site: 'kimi',\n    name: 'sidebar-toggle',\n    access: 'write',\n    description: 'Click the LeftBar svg to toggle the Kimi sidebar.',\n    domain: KIMI_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/ui.js#L40-L76","documentation":"The kimi mode-switch command looks up the requested mode name in the MODES registry (clis/kimi/ui.js). If the name is not a key of MODES, it throws ArgumentError naming the argument and listing valid modes. This is a fail-fast input validation guard so the driver never navigates to an undefined Kimi route.","triggerScenarios":"Calling the kimi mode command with a name that is not a key of MODES, e.g. a typo, different casing, or a mode from another site's CLI ('kimi', mode='history-all' instead of the registered key).","commonSituations":"Typo in mode name; using a mode name copied from another CLI site module; casing mismatch ('Chat' vs 'chat'); renaming of MODES keys after a library update while scripts still pass the old literal.","solutions":["Run the command without a mode (or list modes) to see the valid names printed in the error's Known: list.","Correct the mode name to one of the exact keys in MODES (match spelling and casing).","Validate the mode against Object.keys(MODES) before calling the command in automation scripts.","Update the library if the mode was recently added and your installed version predates it."],"exampleFix":"// before\nawait run('kimi', 'mode', { name: 'chat-history' });\n// after\nawait run('kimi', 'mode', { name: 'history' }); // a key that exists in MODES","handlingStrategy":"validation","validationCode":"const MODES = ['chat','history' /* per Known: list */];\nif (!MODES.includes(name)) throw new Error(`invalid mode: ${name}`);\nawait run('kimi', 'mode', { name });","typeGuard":"const isValidMode = (n) => typeof n === 'string' && MODES.includes(n);","tryCatchPattern":"try {\n  await run('kimi', 'mode', { name });\n} catch (e) {\n  if (/unknown mode/.test(e.message)) {\n    const known = e.message.match(/Known: (.*)/)?.[1].split(', ');\n    console.error(`Pick a mode from: ${known.join(', ')}`);\n  } else throw e;\n}","preventionTips":["Keep a shared constant of valid mode names imported by all automation scripts.","Echo the Known: list from the error message when building interactive pickers.","Add a unit test asserting every mode literal used in scripts exists in MODES."],"tags":["argument-validation","cli","kimi"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}