Skip to content

feat: emit JSON for env list, database list/query, and logs (NDJSON)#93

Open
crowlbot wants to merge 1 commit into
feat/agent-non-interactivefrom
feat/agent-json-outputs
Open

feat: emit JSON for env list, database list/query, and logs (NDJSON)#93
crowlbot wants to merge 1 commit into
feat/agent-non-interactivefrom
feat/agent-json-outputs

Conversation

@crowlbot
Copy link
Copy Markdown

Summary

Stacked on #92 (which is stacked on #91). Wires the --json global flag from #91 into the list/inspect commands an agent would normally pipe into `jq`.

What's in this PR

  • `env list --json` — array of { id, key, value, isSecret, contexts }. Secret values come back as null rather than the human-mode *** placeholder, so agents can distinguish "secret" from "literally three asterisks". Contexts are resolved to names.
  • `database list --json` — array of database instances with name, engine, createdAt, assignments (app slugs), connection (the safe-to-display fields), and a nested databases array.
  • `database query --json`:
    • On success: { rows: [...] }.
    • On failure: the existing structured-error envelope on stderr with errorCode: POSTGRES_ERROR or QUERY_ERROR.
  • `logs --json`NDJSON: one log record per line on stdout, fields flattened to lowerCamelCase (timestamp, traceId, spanId, severity, severityNumber, body, scope, revision, attributes). The "connected, streaming logs" preamble is suppressed in JSON mode. Pipes cleanly into `jq -c .` or `grep -F`.

Human output is unchanged when --json is not set.

Test plan

  • deno fmt clean
  • deno lint clean
  • deno check main.ts — 114 errors, same as main. No new regressions.
  • deno test -A tests/agent.test.ts tests/create.test.ts23/23 pass.
  • Verified env list --json payload shape against the existing EnvVar shape in the tRPC query.
  • Verified database list --json payload against the response type already declared in the file.
  • Streaming logs --json writes via `Deno.stdout.writeSync` to avoid color/buffering interleaving with stderr.

Follow-up

New list subcommands (`apps list`, `orgs list`, `deployments list`) come in the next PR — keeping this one tight.

🤖 Generated with Claude Code

Third slice of the agent-ergonomics series. Wires `--json` (from #91)
into the list/inspect commands that an agent would normally pipe into
`jq`:

- `env list --json` — array of `{ id, key, value, isSecret, contexts }`.
  Secret values are emitted as `null` rather than the `***` placeholder
  so agents can tell "secret" from "literally three asterisks". Contexts
  are resolved to names.
- `database list --json` — array of database instances with `name`,
  `engine`, `createdAt`, `assignments` (app slugs), `connection` (the
  safe-to-display fields), and a nested `databases` array.
- `database query --json` — `{ rows: [...] }` on success;
  `{ error: { code, message, ... } }` (via the existing error envelope)
  with errorCode `POSTGRES_ERROR` or `QUERY_ERROR` on failure.
- `logs --json` — NDJSON: one log record per line on stdout, fields
  flattened to lowerCamelCase (`timestamp`, `traceId`, `severity`,
  `severityNumber`, `body`, `scope`, `revision`, `attributes`). Pipes
  cleanly into `jq -c .` or `grep -F`. The "connected, streaming logs"
  preamble is suppressed.

Human output is unchanged when `--json` is not set.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@crowlbot crowlbot force-pushed the feat/agent-json-outputs branch from dabbbef to 3594eb9 Compare May 13, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant