{"record":{"id":"647221324442fa36","repo":"can1357/oh-my-pi","slug":"no-snippet-provided-pass-inline-text-file-pat","errorCode":null,"errorMessage":"No snippet provided. Pass inline text, --file <path>, or pipe via --file -.","messagePattern":"No snippet provided\\. Pass inline text, --file <path>, or pipe via --file -\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/ttsr-cli.ts","lineNumber":162,"sourceCode":"\tpath: string;\n\tsize?: number;\n}\n\nasync function readSnippet(opts: { snippet?: string; file?: string }): Promise<string> {\n\tif (opts.file) {\n\t\tif (opts.file === STDIN_MARKER) {\n\t\t\treturn await Bun.stdin.text();\n\t\t}\n\t\tconst resolved = path.resolve(opts.file);\n\t\tconst file = Bun.file(resolved);\n\t\tif (!(await file.exists())) {\n\t\t\tthrow new Error(`Snippet file not found: ${resolved}`);\n\t\t}\n\t\treturn await file.text();\n\t}\n\tif (opts.snippet !== undefined) return opts.snippet;\n\tif (process.stdin.isTTY === false) return await Bun.stdin.text();\n\tthrow new Error(\"No snippet provided. Pass inline text, --file <path>, or pipe via --file -.\");\n}\n\nfunction previewSnippet(text: string): string {\n\tconst single = text.replace(/\\s+/g, \" \").trim();\n\treturn single.length > 80 ? `${single.slice(0, 77)}…` : single;\n}\n\nfunction deriveLang(filePaths: string[] | undefined): string | undefined {\n\tfor (const filePath of filePaths ?? []) {\n\t\tconst ext = path.extname(filePath.replaceAll(\"\\\\\", \"/\"));\n\t\tif (ext.length > 1) return ext.slice(1).toLowerCase();\n\t}\n\treturn undefined;\n}\n\nasync function regexMatches(rule: Rule, snippet: string): Promise<string[]> {\n\tconst out: string[] = [];\n\tfor (const pattern of rule.condition ?? []) {","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/ttsr-cli.ts#L144-L180","documentation":"`omp ttsr test` needs snippet text to run rules against. readSnippet checks, in order: --file (path or `-` for stdin), inline snippet argument, then piped stdin. If none is provided — no snippet arg, no --file, and stdin is a TTY so nothing is piped — it throws this usage error explaining the three accepted input modes.","triggerScenarios":"Running `omp ttsr test --rule <rule.md>` with no snippet source at all; forgetting the positional snippet while running interactively (stdin.isTTY === true); passing only flags like --source/--tool without any snippet.","commonSituations":"Copy-pasting a command from docs that assumed piped input; running in a terminal without piping (`cat file | omp ttsr test ...`); scripted invocation where an upstream step produced empty output and the snippet variable was dropped.","solutions":["Pass the snippet inline: `omp ttsr test \"<text>\" --rule <rule.md>`.","Pass a file: `omp ttsr test --file <path> --rule <rule.md>`.","Pipe the snippet: `cat file.ts | omp ttsr test --rule <rule.md>` or use `--file -`.","If scripting, assert the snippet variable is non-empty before invoking."],"exampleFix":"// before\nomp ttsr test --rule rules/no-api-keys.md        # no input\n// after\ncmp ttsr test --file src/api.ts --rule rules/no-api-keys.md","handlingStrategy":"validation","validationCode":"const hasInput = Boolean(args.snippet) || Boolean(args.file) || !process.stdin.isTTY;\nif (!hasInput) {\n  process.exitCode = 2;\n  console.error(\"Provide a snippet: inline text, --file <path>, or pipe via --file -.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runTtsrCommand(args);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"No snippet provided\")) {\n    console.error(err.message);\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Always pass one of: positional snippet, --file, or a pipe.","In scripts, assert snippet variable non-empty: `: \"${SNIPPET:?empty}\"`.","Remember interactive terminals make stdin a TTY, so nothing is 'piped'.","Wrap complex pipelines: `content=$(cmd) || exit; omp ttsr test \"$content\" ...`."],"tags":["cli","usage","missing-argument","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}