Add the CLI API client, preflight prompts and sc apps #11

Merged
geusebio merged 2 commits from feature/sc-cli-api into main 2026-08-03 18:57:46 +00:00
Owner

Three things, all riding on the new /cli/* API in the platform (see its PR).

A client for itinternal/client/cliapi.go: organizations, applications, a preflight lookup and application creation. Errors come back as a typed APIError that records whether the platform actually explained itself, which is what lets the CLI tell "no such application" from "no such route".

deploy asks before it uploads. A preflight resolves the target first, so two things a detected name can get wrong become questions rather than a failed upload:

$ sc deploy
No application "example-app" on http://127.0.0.1:7500.
Create application "example-app" in "grey-ooo"? [Y/n] y
Created example-app — http://127.0.0.1:7500/applications/019f…

$ sc deploy --deployment feature-ui
"example-app" has no deployment called "feature-ui" yet (it has: main).
Start a new deployment "feature-ui"? [Y/n]

A first-ever deployment is not asked about — nothing for it to be a departure from. Answers come from stdin, so printf "y\\n" | sc deploy works like typing it; nothing to read from is an error naming --yes, never a hang. --org picks the organization when you belong to several, and now reaches the upload URL too, so an ambiguous slug is finally resolvable from the CLI.

sc apps prints organizations → applications → deployments as a tree, with an optional filter that keeps a match's ancestors — so filtering by a deployment name still shows you where it lives.

Degrades rather than breaks

sc ships separately from the server and will routinely be the newer of the two. A 404 from a route that does not exist is not read as "the application does not exist": the preflight warns once and uploads exactly as before, and sc apps says <endpoint> has no /cli API — needs a newer platform.

Verified

go vet and go test ./... clean, with new tests for the client, the prompt branches (accept, decline, no-answer), the older-platform path and the tree filter. Exercised end to end against a local stack: created an application from the prompt, declined a new deployment name, and drew the tree.

Three things, all riding on the new `/cli/*` API in the platform (see its PR). **A client for it** — `internal/client/cliapi.go`: organizations, applications, a preflight lookup and application creation. Errors come back as a typed `APIError` that records whether the platform actually explained itself, which is what lets the CLI tell "no such application" from "no such route". **`deploy` asks before it uploads.** A preflight resolves the target first, so two things a *detected* name can get wrong become questions rather than a failed upload: ``` $ sc deploy No application "example-app" on http://127.0.0.1:7500. Create application "example-app" in "grey-ooo"? [Y/n] y Created example-app — http://127.0.0.1:7500/applications/019f… $ sc deploy --deployment feature-ui "example-app" has no deployment called "feature-ui" yet (it has: main). Start a new deployment "feature-ui"? [Y/n] ``` A first-ever deployment is not asked about — nothing for it to be a departure from. Answers come from stdin, so `printf "y\\n" | sc deploy` works like typing it; nothing to read from is an error naming `--yes`, never a hang. `--org` picks the organization when you belong to several, and now reaches the upload URL too, so an ambiguous slug is finally resolvable from the CLI. **`sc apps`** prints organizations → applications → deployments as a tree, with an optional filter that keeps a match's ancestors — so filtering by a deployment name still shows you where it lives. ## Degrades rather than breaks `sc` ships separately from the server and will routinely be the newer of the two. A 404 from a route that does not exist is *not* read as "the application does not exist": the preflight warns once and uploads exactly as before, and `sc apps` says `<endpoint> has no /cli API — needs a newer platform`. ## Verified `go vet` and `go test ./...` clean, with new tests for the client, the prompt branches (accept, decline, no-answer), the older-platform path and the tree filter. Exercised end to end against a local stack: created an application from the prompt, declined a new deployment name, and drew the tree.
Cover the API waits with the spinner
All checks were successful
CI / build (pull_request) Successful in 10m11s
3ea24e800f
The preflight lookup, the organization list, the application creation and
`sc apps` all sit on the network with nothing on screen. Each gets the wait
spinner: erased on success so a fast answer leaves no trace, and Done leaving
one line where a summary is worth keeping.
Sign in to join this conversation.
No reviewers
No labels
in-progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grey.ooo/someones.computer_agent!11
No description provided.