One error shape for every agent surface: the CLI's stderr line, its --json error and an MCP tool error all carry the same fields, so an agent learns one repair loop. The line mirrors Ouro HX's dev message format: <tool>: <thing>: <what's wrong>. Fix: <exact code>.
npx shadcn@latest add ourostack/ouro-ui/ax-problem#v1.3.10It installs lib/ouro/ax/problem.ts. Its tests are ax-problem-tests. Every item runs on Node 22.18 or later as it is copied: the files import each other as ./<file>.ts. The Ouro AX guide shows how they fit together.
Exports
AxError
The error the kit's primitives throw: its message is the one line, its shape the data.
class AxError extends ErrorAxErrorBody
The error as data: its shape plus the one-line message. Outcomes, --json and MCP all carry this.
type AxErrorBody = AxErrorShape & { message: string };AxErrorShape
One error shape for every agent surface: the CLI's stderr line, its --json error and an MCP tool error all carry the same fields, so an agent learns one repair loop. The line mirrors Ouro HX's dev message format: <tool>: <thing>: <what's wrong>. Fix: <exact code>.
interface AxErrorShape {
code: string;
exit: number;
thing: string;
problem: string;
fix: string | null;
}commandLine
A command line from words, each quoted only when it needs it.
function commandLine(words: readonly string[]): stringdidYouMean
The candidate an agent most likely meant: a unique prefix, or the nearest within two edits; null when none is close.
function didYouMean(word: string, candidates: readonly string[]): string | nullerrorJson
The --json and MCP form: { error: { code, exit, thing, problem, fix, message } }.
function errorJson(shape: AxErrorShape): { error: AxErrorBody; }errorLine
The one stderr line: <tool>: <thing>: <problem>. Fix: <fix>. Line breaks in any part become spaces.
function errorLine(tool: string, shape: Pick<AxErrorShape, "fix" | "thing" | "problem">): stringerrorMessage
<thing>: <problem>. Fix: <fix>., without the tool's prefix (a CLI adds its own).
function errorMessage(shape: Pick<AxErrorShape, "fix" | "thing" | "problem">): stringisAxError
function isAxError(value: unknown): value is AxErrorshellWord
Quotes a word for a POSIX shell only when it needs it, so a fix copies and runs as printed.
function shellWord(word: string): string