can1357/oh-my-pi · error · Error
No snippet provided. Pass inline text, --file <path>, or pip
Error message
No snippet provided. Pass inline text, --file <path>, or pipe via --file -.
What it means
`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.
Source
Thrown at packages/coding-agent/src/cli/ttsr-cli.ts:162
path: string;
size?: number;
}
async function readSnippet(opts: { snippet?: string; file?: string }): Promise<string> {
if (opts.file) {
if (opts.file === STDIN_MARKER) {
return await Bun.stdin.text();
}
const resolved = path.resolve(opts.file);
const file = Bun.file(resolved);
if (!(await file.exists())) {
throw new Error(`Snippet file not found: ${resolved}`);
}
return await file.text();
}
if (opts.snippet !== undefined) return opts.snippet;
if (process.stdin.isTTY === false) return await Bun.stdin.text();
throw new Error("No snippet provided. Pass inline text, --file <path>, or pipe via --file -.");
}
function previewSnippet(text: string): string {
const single = text.replace(/\s+/g, " ").trim();
return single.length > 80 ? `${single.slice(0, 77)}…` : single;
}
function deriveLang(filePaths: string[] | undefined): string | undefined {
for (const filePath of filePaths ?? []) {
const ext = path.extname(filePath.replaceAll("\\", "/"));
if (ext.length > 1) return ext.slice(1).toLowerCase();
}
return undefined;
}
async function regexMatches(rule: Rule, snippet: string): Promise<string[]> {
const out: string[] = [];
for (const pattern of rule.condition ?? []) {View on GitHub (pinned to 9690622007)
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.
Example fix
// before omp ttsr test --rule rules/no-api-keys.md # no input // after cmp ttsr test --file src/api.ts --rule rules/no-api-keys.md
Defensive patterns
Strategy: validation
Validate before calling
const hasInput = Boolean(args.snippet) || Boolean(args.file) || !process.stdin.isTTY;
if (!hasInput) {
process.exitCode = 2;
console.error("Provide a snippet: inline text, --file <path>, or pipe via --file -.");
} Try / catch
try {
await runTtsrCommand(args);
} catch (err) {
if (err instanceof Error && err.message.startsWith("No snippet provided")) {
console.error(err.message);
process.exitCode = 2;
} else throw err;
} Prevention
- 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" ...`.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Usage: omp auth-broker import <file|dir> [--provider=<id>] [
- Pass at least one model selector, e.g. `omp bench opus gpt-5
- --agents must be a positive integer
- --rounds must be a positive integer
- --agents must be a positive integer
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/647221324442fa36.
Report an issue: GitHub.