services add compute --image/--port (create-with-image CLI)#63
Conversation
… list services add <compute> <name> now accepts --image <url> and --port <n>, forwarded to POST /projects/:id/services as image/port. Both are rejected client-side for non-compute types (mirrors the existing --public/storage-only check), throwing before any network/config access. Extracted servicesAddRequestBody (mirrors deployRequestBody) so the option-to-body mapping is unit-tested without mocking the API client. services list now shows the running image (and port, if any) on compute rows via a new serviceListLine helper, extracted for the same reason (mirrors billingLines).
jwfing
left a comment
There was a problem hiding this comment.
Summary
Clean, well-scoped, thoroughly-tested thin-client change: adds compute-only --image/--port to insta services add and surfaces the running image in insta services list, following the repo's existing pure-helper + validation conventions. No blocking issues.
Requirements context
No matching spec/plan found — this repo has no docs/superpowers/ or docs/specs/ directory (top level is src/, test/, AGENTS.md, etc.). Assessed against the PR description, the paired insta-platform PR #54 contract described in the body, and in-repo conventions (AGENTS.md, src/commands/deploy.ts). Verified locally: npm run typecheck clean and npm test → 105 passing, matching the PR's stated results.
Findings
Critical
(none)
Suggestion
-
Functionality — no numeric validation on
--port(src/commands/services.ts:56).servicesAddRequestBodydoes...(opts.port ? { port: Number(opts.port) } : {}). A non-numeric value like--port abcmakesNumber('abc') → NaN, which JSON-serializes toport: nulland is sent silently (a user typo becomes a no-op rather than an error).--port 0is likewise passed through as an invalid0. This is a pre-existing pattern (deployRequestBodyinsrc/commands/deploy.ts:16has the same behavior), and the PR body already flags it as a follow-up, so it's non-blocking — but the in-fileparseCounthelper (services.ts:20) is the ready-made pattern to reuse for a fail-fast error. Non-blocking, low blast radius. -
Functionality —
--portaccepted without--image(src/commands/services.ts:63-64). Validation checks only that the type iscompute;insta services add compute api --port 3000(no image) is accepted and sends a bareport. If the platform ignores/rejects a port with no image this is harmless, but rejecting it client-side (or documenting that--portimplies--image) would give a clearer error. Minor; server behavior via PR #54 governs the real outcome.
Information
-
Convention — agent-facing flag doc lives outside this repo.
AGENTS.mdnon-negotiable #4 requires command/flag changes to be mirrored inskills/insta/cli-reference.mdin the insta-cloud superproject'sskills/submodule. That file isn't in this repo so it can't be part of this PR, but the two new flags should be reflected there as a follow-up so the agent-facing surface doc stays in sync. -
Software engineering — test coverage is strong. New tests exercise body inclusion/omission of
image/port, the port-as-number coercion, validation throwing before any network/config access (nice, matches the helper's comment), and allserviceListLinerender branches (image+port, image-only, no image, storage, postgres). This is the kind of coverage that would have caught a close-call regression in the list rendering. -
Security — no concerns. The image URL and port are user input but flow only into a JSON body via
api.rawRequest(no SQL/shell/string interpolation), no secrets/PII are newly logged or returned, and no auth/authorization paths change. -
Performance — no concerns.
serviceListLineis O(1) per row (same cost as the inlined code it replaces); no new queries, loops, or allocations.
Verdict
approved (informational — a human still gives the explicit GitHub approval). Zero Critical findings; the Suggestions are non-blocking and largely already acknowledged as follow-ups in the PR description.
Fermionic-Lyu
left a comment
There was a problem hiding this comment.
LGTM, Approved. (Relaying John-bot's approved verdict — approved with the maintainer account, since John-bot can't approve its own PR.)
…--port) Both PRs extended 'services add': #61 added --region + client-side region guard; #63 (on main) added --image/--port + servicesAddRequestBody. Resolved by folding region into servicesAddRequestBody and the servicesAdd validation/output; dropped the now-redundant buildAddServiceBody + its test, moved region coverage into test/services.test.ts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What & why
CLI side of compute create-with-image.
insta services add compute <name>gains:--image <url>— run this container image at creation (compute only)--port <n>— port the image listens on (compute only; server defaults to 8080)Both are rejected client-side for non-compute types (mirrors the existing
--publicstorage-only check).insta services listnow shows the running image for compute services (running <image>[:<port>]).Pairs with insta-platform PR #54 (server accepts
image/portonPOST /servicesand returns them onService). This CLI is a thin client, so the change is self-contained and unit-tested without a live platform.Implementation
servicesAdd(src/commands/services.ts): compute-only validation for--image/--port; request body extracted into a pureservicesAddRequestBody(...)helper (mirroring the existingdeployRequestBody/billingLinesconvention) that includesimage/portonly when provided.servicesList: line rendering extracted intoserviceListLine(...), which shows the image for compute rows.src/index.ts:--image/--portoptions on theservices addcommand.Testing
npm run typecheck+npm run buildclean;npm test105 tests pass (services.test.ts12→27, covering: body includes image/port when passed, omits them when absent, rejects--image/--porton non-compute, and the compute list-line render).services add --helpshows both flags.Follow-ups (not in this PR)
--portisn't format-validated (--port abcwould sendport:null); the in-fileparseCounthelper is the pattern to reuse — recommended small follow-up.🤖 Generated with Claude Code
Summary by cubic
Adds create-with-image support to the CLI.
insta services add compute <name>now accepts--imageand--port, andinsta services listshows the running image (with port).New Features
--image <url>and--port <n>oninsta services add compute <name>; sent asimageand numericportto the API (server default port is 8080).--image/--portare compute-only; mirrors existing--publicstorage-only check.services listshows compute images asrunning <image>[:<port>].Refactors
servicesAddRequestBody(...)to build the POST body andserviceListLine(...)for list rendering; both are pure and unit-tested.Written for commit cd3f5fe. Summary will update on new commits.