Skip to content

services add compute --image/--port (create-with-image CLI)#63

Merged
jwfing merged 1 commit into
mainfrom
feat/compute-service-image
Jul 21, 2026
Merged

services add compute --image/--port (create-with-image CLI)#63
jwfing merged 1 commit into
mainfrom
feat/compute-service-image

Conversation

@jwfing

@jwfing jwfing commented Jul 20, 2026

Copy link
Copy Markdown
Member

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 --public storage-only check). insta services list now shows the running image for compute services (running <image>[:<port>]).

Pairs with insta-platform PR #54 (server accepts image/port on POST /services and returns them on Service). 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 pure servicesAddRequestBody(...) helper (mirroring the existing deployRequestBody/billingLines convention) that includes image/port only when provided.
  • servicesList: line rendering extracted into serviceListLine(...), which shows the image for compute rows.
  • src/index.ts: --image/--port options on the services add command.

Testing

npm run typecheck + npm run build clean; npm test 105 tests pass (services.test.ts 12→27, covering: body includes image/port when passed, omits them when absent, rejects --image/--port on non-compute, and the compute list-line render). services add --help shows both flags.

Follow-ups (not in this PR)

  • --port isn't format-validated (--port abc would send port:null); the in-file parseCount helper is the pattern to reuse — recommended small follow-up.
  • The add success-message string isn't extracted for a unit test (the request body and validation are).

🤖 Generated with Claude Code


Summary by cubic

Adds create-with-image support to the CLI. insta services add compute <name> now accepts --image and --port, and insta services list shows the running image (with port).

  • New Features

    • --image <url> and --port <n> on insta services add compute <name>; sent as image and numeric port to the API (server default port is 8080).
    • Client-side validation: --image/--port are compute-only; mirrors existing --public storage-only check.
    • services list shows compute images as running <image>[:<port>].
  • Refactors

    • Extracted servicesAddRequestBody(...) to build the POST body and serviceListLine(...) for list rendering; both are pure and unit-tested.

Written for commit cd3f5fe. Summary will update on new commits.

Review in cubic

… 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 jwfing left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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). servicesAddRequestBody does ...(opts.port ? { port: Number(opts.port) } : {}). A non-numeric value like --port abc makes Number('abc') → NaN, which JSON-serializes to port: null and is sent silently (a user typo becomes a no-op rather than an error). --port 0 is likewise passed through as an invalid 0. This is a pre-existing pattern (deployRequestBody in src/commands/deploy.ts:16 has the same behavior), and the PR body already flags it as a follow-up, so it's non-blocking — but the in-file parseCount helper (services.ts:20) is the ready-made pattern to reuse for a fail-fast error. Non-blocking, low blast radius.

  • Functionality — --port accepted without --image (src/commands/services.ts:63-64). Validation checks only that the type is compute; insta services add compute api --port 3000 (no image) is accepted and sends a bare port. If the platform ignores/rejects a port with no image this is harmless, but rejecting it client-side (or documenting that --port implies --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.md non-negotiable #4 requires command/flag changes to be mirrored in skills/insta/cli-reference.md in the insta-cloud superproject's skills/ 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 all serviceListLine render 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. serviceListLine is 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 Fermionic-Lyu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Approved. (Relaying John-bot's approved verdict — approved with the maintainer account, since John-bot can't approve its own PR.)

@jwfing
jwfing merged commit fea548e into main Jul 21, 2026
2 checks passed
jwfing added a commit that referenced this pull request Jul 21, 2026
…--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>
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