-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
All CLI output is human-formatted (emoji, Unicode box-drawing, banners). There is no machine-readable output mode. This blocks two scenarios:
- Agent consumption — coding agents (Copilot CLI agent, Claude, etc.) cannot reliably parse CLI output to take follow-up actions
- Scripting — users who want to pipe
gh devlakeoutput intojq, dashboards, or automation scripts must screen-scrape
The Playwright CLI demonstrates the pattern: CLI commands return structured snapshots to stdout that agents consume directly. For gh-devlake, the equivalent is structured JSON from read commands.
Proposed Solution
Add a --json flag (or --output json) to all read-only commands. When set:
- Suppress emoji, banners, box-drawing, and interactive prompts
- Print a single JSON object to stdout
- Exit with code 0 on success, non-zero on error (with JSON error body)
Commands to update
| Command | JSON output shape |
|---|---|
status |
{ deployment: {…}, endpoints: [{name, url, healthy}], connections: [{plugin, id, name, healthy}], projects: [{name, blueprintId}] } |
configure connection list |
[{id, plugin, name, endpoint, organization, enterprise}] |
configure scope list (from #55) |
[{scopeId, name, fullName, plugin, connectionId}] |
configure project list (from #56) |
[{name, description, blueprintId}] |
Implementation approach
- Add a package-level
outputJSON boolflag onrootCmd.PersistentFlags()so it's available to all commands - Create a helper
func printJSON(v any) errorincmd/helpers.gothat marshals and writes to stdout - Each command's
RunEchecksoutputJSONearly and branches to a JSON code path that builds a struct and callsprintJSON - Human output remains the default — no behavioral change for interactive users
Example
# Human (default)
$ gh devlake status
╭──────────────────────────────────────────────╮
│ DevLake Status │
╰──────────────────────────────────────────────╯
✅ Backend API: http://localhost:8080
...
# Machine
$ gh devlake status --json
{"deployment":{"method":"local","stateFile":".devlake-local.json"},"endpoints":[{"name":"backend","url":"http://localhost:8080","healthy":true}],"connections":[{"plugin":"github","id":1,"name":"GitHub - my-org","healthy":true}]}Acceptance Criteria
-
--jsonflag available onstatus,configure connection list -
--jsonflag ready forconfigure scope list(configure scope add/list/delete: Add CRUD subcommands for scope management #55) andconfigure project list(configure project add/list/delete: Add CRUD subcommands for project management #56) when they land - JSON output is a single line (no pretty-print by default) for easy piping
- No emoji, banners, or interactive prompts in JSON mode
- Error responses are also JSON:
{"error": "message"} -
go build ./...andgo test ./...pass
Target Version
v0.4.x — Foundation for agent-friendly CLI and AI features.
References
- Playwright CLI pattern:
microsoft/playwright-cli— commands return structured output that agents consume via stdout. See the snapshot mechanism where each command emits a parseable snapshot. cmd/status.go— current human-formatted status outputcmd/configure_connection_list.go— current human-formatted connection listcmd/helpers.go—printBanner()and other output helpersconfigure scope add/list/delete: Add CRUD subcommands for scope management #55 —configure scope list(will need--jsonsupport)configure project add/list/delete: Add CRUD subcommands for project management #56 —configure project list(will need--jsonsupport)
Reactions are currently unavailable
Metadata
Metadata
Labels
enhancementNew feature or requestNew feature or request