Labs / Lab 02

Wrap the CLI in a stable JSON interface

Move from human-friendly text to one output shape that callers can depend on.

What this adds

Make tool output machine-readable.

The term counter already works for humans. This lab makes it safer for automation by returning a predictable JSON envelope with success, items, summary data, and errors.

Once that shape is stable, other layers can validate, log, replay, and compose tool calls without scraping loose text.

Boundary

The wrapper becomes the contract. Callers should rely on the JSON shape, not on the exact stdout format of the underlying script.

Done when

Success and failure both return valid JSON, and callers can inspect the result without regex or brittle parsing.

Real-world analog

ripgrep's JSON mode shows the same pattern: a familiar CLI plus a machine-readable output format for editors, hosts, and automation.

Why this matters

Structured output is the difference between "I can maybe use this in a loop" and "I can trust this in a host."

Next lab

Lab 03: add a protocol adapter.