From bef3cc7dd95745a5724d3569e45fe7be4aba02ee Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 24 Mar 2026 17:44:37 +0200 Subject: ask: add --json flag for machine-readable output List, ready, all, info, and urgency commands now output JSON arrays when --json is passed. This fixes pi agent-plan-mode extension which expects JSON from ask but was getting human-readable tables. Amp-Thread-ID: https://ampcode.com/threads/T-019d207c-b8e2-748d-af52-dd8f84fb2b32 Co-authored-by: Amp --- internal/askcli/dispatch.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'internal/askcli/dispatch.go') diff --git a/internal/askcli/dispatch.go b/internal/askcli/dispatch.go index 312a6cf..19e9b58 100644 --- a/internal/askcli/dispatch.go +++ b/internal/askcli/dispatch.go @@ -11,7 +11,8 @@ type Runner interface { } type Dispatcher struct { - runner Runner + runner Runner + jsonOutput bool } func NewDispatcher(runner Runner) *Dispatcher { @@ -23,6 +24,19 @@ func NewDispatcher(runner Runner) *Dispatcher { } func (d Dispatcher) Dispatch(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { + // Extract --json flag before dispatching. + var jsonOutput bool + var filtered []string + for _, a := range args { + if a == "--json" { + jsonOutput = true + } else { + filtered = append(filtered, a) + } + } + args = filtered + d.jsonOutput = jsonOutput + if len(args) == 0 { return d.handleList(ctx, []string{"list"}, stdout, stderr) } -- cgit v1.2.3