Skip to content

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

Merged
crowlKats merged 1 commit into
mainfrom
feat/agent-json-outputs
May 28, 2026
Merged

feat: emit JSON for env list, database list/query, and logs (NDJSON)#93
crowlKats merged 1 commit into
mainfrom
feat/agent-json-outputs

Conversation

@crowlbot
Copy link
Copy Markdown
Contributor

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

@crowlKats crowlKats force-pushed the feat/agent-non-interactive branch from 535af87 to a5f6ea0 Compare May 28, 2026 09:13
Base automatically changed from feat/agent-non-interactive to main May 28, 2026 09:31
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>
@crowlKats crowlKats force-pushed the feat/agent-json-outputs branch from 3594eb9 to 9494816 Compare May 28, 2026 09:33
@crowlKats crowlKats enabled auto-merge (squash) May 28, 2026 09:34
@crowlKats crowlKats merged commit 7acdfc3 into main May 28, 2026
4 checks passed
@crowlKats crowlKats deleted the feat/agent-json-outputs branch May 28, 2026 09:36
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.

2 participants