Skip to content

feat: add sp CLI — command-line client for the platform REST API#1121

Open
gaurav02081 wants to merge 3 commits into
CCExtractor:masterfrom
gaurav02081:feat/sp-cli
Open

feat: add sp CLI — command-line client for the platform REST API#1121
gaurav02081 wants to merge 3 commits into
CCExtractor:masterfrom
gaurav02081:feat/sp-cli

Conversation

@gaurav02081

Copy link
Copy Markdown

Summary

Adds sp_cli — an agent- and script-friendly command-line client for the platform's REST API (/api/v1). Emits JSON by default (so it can be driven by scripts and AI agents) with an --output table mode for humans.

Commands

  • sp health, sp queue — system status
  • sp run ls / show / summary / failures / results / result / diff / logs / errors / approve-baseline
  • sp sample ls / show / history, sp regression ls
  • sp auth login / logout, sp investigate

Highlights

  • Failure classifier (run failures, investigate): turns raw signals (exit code, output diff) into a triage verdict with a confidence level and a plain-language reason — so a person or an agent learns why a test failed without reading logs.
  • Validated end-to-end against the REST API endpoints: fixed the diff endpoint contract, aligned status vocabulary, and added approve-baseline (admin-only, with the cross-platform baseline warning).
  • 32 CLI tests; passes the same checks CI runs (pycodestyle / isort / pydocstyle).

Status / dependency

Opening as a draft: the CLI consumes the REST API endpoints introduced in #1117, which is not yet merged. The sp_cli package and its tests are self-contained (tests mock the HTTP client), so this passes CI independently. I'll mark it ready for review once #1117 lands.

Notes

  • run.py gains a DISABLE_GCS=1 environment flag so the app can boot locally without GCS credentials (useful for development and for exercising the CLI).

@gaurav02081 gaurav02081 changed the title feat: add sp CLI — command-line client for the platform REST API feat: add sp CLI — command-line client for the platform REST API (WIP) Jun 14, 2026
sp is an AI- and human-friendly CLI over the platform's /api/v1 REST API.
It lets an agent or developer investigate CI runs end-to-end from the
terminal (no web frontend): list/show runs, summaries, classified
failures, expected-vs-actual diffs, logs, errors, artifacts, samples,
regression tests, auth, and a one-shot `investigate` triage command.

Output defaults to JSON for agents, with a `-o table` human view. The API
address is configurable via --base-url / SP_BASE_URL, so it points at any
deployment without code changes. Dependencies are pinned via uv.lock.
Add a DISABLE_GCS escape hatch in run.py so the server can boot for local
development and CLI testing without Google Cloud Storage credentials, and
guard serve_file_download to fail clearly (503) when the storage bucket is
unavailable instead of dereferencing None.
Cover the HTTP client (URL building, error/exit-code mapping, pagination),
the failure classifier, the triage helpers, and the command surface via
click's CliRunner against a mocked client.
@sonarqubecloud

Copy link
Copy Markdown

@gaurav02081 gaurav02081 changed the title feat: add sp CLI — command-line client for the platform REST API (WIP) feat: add sp CLI — command-line client for the platform REST API Jun 21, 2026
@gaurav02081 gaurav02081 marked this pull request as ready for review June 21, 2026 19:27
@gaurav02081

Copy link
Copy Markdown
Author

@canihavesomecoffee Hii ,
Looking Forward to Your Feedback .

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