{"record":{"id":"aba435bdc640e980","repo":"jackwener/OpenCLI","slug":"prompt","errorCode":null,"errorMessage":"prompt","messagePattern":"prompt","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/yuanbao/send.js","lineNumber":30,"sourceCode":"\ncli({\n    site: 'yuanbao',\n    name: 'send',\n    access: 'write',\n    description: 'Fire-and-forget: send a prompt to Yuanbao without waiting for the reply',\n    domain: YUANBAO_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'prompt', positional: true, required: true, help: 'Prompt to send to Yuanbao' },\n        { name: 'new', type: 'boolean', default: false, help: 'Start a new chat before sending' },\n    ],\n    columns: ['Status', 'Prompt'],\n    func: async (page, kwargs) => {\n        const prompt = String(kwargs.prompt || '').trim();\n        if (!prompt) throw new ArgumentError('prompt', 'is required');\n        const startFresh = normalizeBooleanFlag(kwargs.new, false);\n\n        await ensureYuanbaoPage(page);\n        if (await hasLoginGate(page)) {\n            throw authRequired('Yuanbao opened a login gate before sending the prompt.');\n        }\n        if (startFresh) {\n            const action = await startNewYuanbaoChat(page);\n            if (action === 'blocked') {\n                throw authRequired('Yuanbao opened a login gate while starting a new chat.');\n            }\n        }\n        const send = await sendYuanbaoMessage(page, prompt);\n        if (!send?.ok) {\n            if (await hasLoginGate(page)) {\n                throw authRequired('Yuanbao opened a login gate instead of accepting the prompt.');\n            }\n            throw new CommandExecutionError(","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yuanbao/send.js#L12-L48","documentation":"The yuanbao send command requires a positional `prompt` argument. The handler trims the stringified value and throws ArgumentError('prompt','is required') when nothing usable remains. The terse message 'prompt' is the bare argument name surfaced by the CLI argument-error formatter.","triggerScenarios":"Running `yuanbao send` with no positional argument, or passing only whitespace (e.g. `yuanbao send \"   \"`), so String(kwargs.prompt||'').trim() yields ''.","commonSituations":"Scripted calls where the prompt variable is empty/unset; shell quoting bugs that drop the argument; piping intended to supply stdin when the command only reads argv.","solutions":["Pass the prompt as a quoted positional: `yuanbao send \"Summarize this article\"`","Check the calling script for an empty PROMPT variable before invoking","If the prompt may contain newlines/special chars, single-quote it or write it to a file and use $(cat file) carefully"],"exampleFix":"// before\nyuanbao send\n// after\nyuanbao send \"Explain event loop in JS\"","handlingStrategy":"validation","validationCode":"if (typeof prompt !== 'string' || !prompt.trim()) {\n  throw new Error('prompt is required and must be non-empty');\n}","typeGuard":"const hasPrompt = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n  await cli.yuanbaoSend(prompt);\n} catch (e) {\n  if (e.name === 'ArgumentError' && e.param === 'prompt') {\n    console.error('Usage: yuanbao send \"<prompt>\"');\n  } else throw e;\n}","preventionTips":["Always quote positional prompts in shell scripts","Check prompt variables for empty/whitespace before invoking","Avoid relying on stdin piping — the command reads argv only"],"tags":["validation","argument-error","cli"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}