Skip to main content

Ouro AX

ax-problem

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.10

It 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 Error

AxErrorBody

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[]): string

didYouMean

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 | null

errorJson

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">): string

errorMessage

<thing>: <problem>. Fix: <fix>., without the tool's prefix (a CLI adds its own).

function errorMessage(shape: Pick<AxErrorShape, "fix" | "thing" | "problem">): string

isAxError

function isAxError(value: unknown): value is AxError

shellWord

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