Skip to content
Lyncat Tria

Scripts and --json

tria behaves well outside the terminal: no colors or animations when nobody’s watching, JSON for reading from another program, and exit codes that tell you what happened.

In a script, nobody can answer questions. A command that would need to ask something exits with an error, unless you tell it what to do with an option.

No questions

CommandSo it doesn’t ask
tria sort--auto applies what’s clear; --dry-run and --json, on their own, don’t move anything.
tria init--template with its template; with --learn, add -y.
tria rules ask-y applies the change without asking.
tria rules learn and tria eval-y accepts the cost without asking.

Without them, tria says “No interactive terminal: use --yes, --auto, --dry-run or --json depending on the command.” and exits with 2. With tria init --template and no terminal, the profile is created empty.

Clean output

If the output isn’t a terminal, tria writes plain text. The waiting animation goes to standard error, so whatever you save to a file comes out clean:

bash
tria sort --dry-run > proposals.txttria sort --dry-run --json > proposals.json

With --json --show-prompt, what’s sent to the AI goes to standard error and standard output stays pure JSON.

The tria sort JSON

json
{  "applied": [    {      "from": "99-Inbox/Scan_20261011_0012.pdf",      "to": "2-Invoices Received/2026/Q4/Invoice Bay Stationery - 2026-10-11.pdf"    }  ],  "cost": 0.00936,  "failed": [],  "items": [    {      "confidence": "high",      "destination": "2-Invoices Received/2026/Q4/Invoice Bay Stationery - 2026-10-11.pdf",      "file": "99-Inbox/Scan_20261011_0012.pdf",      "reason": "Invoice from Bay Stationery dated October 11, 2026.",      "status": "proposal"    }  ],  "model": "claude-sonnet-5-5",  "usage": {    "cacheReadTokens": 5800,    "cacheWriteTokens": 0,    "inputTokens": 2100,    "outputTokens": 400  }}
FieldWhat it is
itemsEach document in the inbox: file, status (proposal, duplicate or pending), destination, confidence (high, medium or low), reason and, if there is one, doubt.
appliedWhat was moved, from from to to.
failedWhat couldn’t be moved, with the reason.
model, usage, costThe model, the tokens and the approximate cost in USD.
interruptedOnly if the batch was cut short, with the reason.

Fields with no value are left out. tria eval --json writes the evaluation report along the same lines.

Exit codes

CodeWhen
0All good. For tria sort, nothing left pending; with --dry-run, as long as there’s no error.
1tria sort leaves documents in the inbox; tria rules ask doesn’t make the change; tria eval --baseline scores lower.
2Something went wrong.
130Interrupted with Ctrl-C.
bash
tria sort --auto --json > today.jsonif [ $? -eq 1 ]; then echo "Documents left in the inbox"; fi

Environment variables

VariableEffect
ANTHROPIC_API_KEY, OPENAI_API_KEYThe key, instead of the one in the Keychain.
NO_COLORNo colors or animations, with any non-empty value.
CLICOLOR_FORCE=1Colors even when the output isn’t a terminal. NO_COLOR wins.
TERM=dumbPlain text, no animations or full screen.
TRIA_LANGThe language of the messages and the help: ca, es or en.
XDG_CONFIG_HOMEWhere to look for tria/config.toml.

Only one process sorts a space at a time. If the app or another tria is sorting it, tria sort exits with 2 and says so: try again when it finishes.