Skip to content

fix(cli): acceptance-findings bugs — template resource flags, --json, exit codes, --env, doctor - #94

Merged
robertohluna merged 1 commit into
mainfrom
fix/cli-acceptance-bugs-20260829
Aug 29, 2026
Merged

fix(cli): acceptance-findings bugs — template resource flags, --json, exit codes, --env, doctor#94
robertohluna merged 1 commit into
mainfrom
fix/cli-acceptance-bugs-20260829

Conversation

@robertohluna

Copy link
Copy Markdown
Contributor

Fixes the five acceptance findings reported by a paying customer against @miosa/cli.

Fixes

  1. templates create resource flags (src/commands/templates.ts)
    Adds --cpu <n>, --memory <val>, --disk <val>, --size <name> (xs/small/medium/large/xl). --memory/--disk accept 4gb / 4096 / 4096mib and are parsed to MiB integers. They are forwarded as cpu_count / memory_mb / disk_size_mb / size. When no resource flags are given, the fields are omitted so the server picks its default — no more hardcoded, unusable shape.

  2. templates create --json emits clean JSON (src/commands/templates.ts)
    In JSON mode the spinner is disabled and every human/status print is suppressed; stdout carries exactly one machine-parseable payload. The error paths (unreadable Dockerfile, invalid flags) also emit a single JSON object.

  3. Nonzero remote sandbox exec fails the CLI (src/commands/sandbox.ts)
    A nonzero remote exit_code now sets process.exitCode (even in --json mode) so CI and && chains detect the failure. Covers the normal exec/run path and --follow.

  4. sandbox exec --env reaches the guest (src/commands/sandbox.ts)
    Verified --env values are sent as an object under the body key env — the field the backend honors and applies to the guest via sh -c — on the direct, --shell-cmd, --follow, --background and --detached paths. Locked with a regression test.

  5. doctor --json is internally consistent (src/commands/doctor.ts)
    A single doctorVerdict() reconciles ok / firstFailure / summary so they never contradict. ok is true iff all required transport/auth/config/Node checks pass. Optional findings (MCP server, action-catalog drift, missing .claude/mcp.json) move to a separate warnings field and no longer flip ok to false or leave firstFailure null. This eliminates the reported ok:false + firstFailure:null + "All layers healthy" contradiction.

Verification

  • npm run build (tsc): clean.
  • npm test: 430 tests pass (67 files), including new regression tests for all five fixes.
  • Live: doctor --json confirmed internally consistent against the API.

No version bump, no publish, no .npmrc changes.

… exit codes, --env, doctor

Addresses the paying-customer acceptance findings:

1. templates create: add --cpu/--memory/--disk/--size and forward them as
   cpu_count / memory_mb / disk_size_mb / size. Memory and disk accept unit
   suffixes (4gb, 4096, 4096mib) parsed to MiB integers. When no resource
   flags are given the fields are omitted so the server picks its default,
   instead of pinning an unusable hardcoded shape.

2. templates create --json: suppress the spinner and all human/status prints
   in JSON mode so stdout carries exactly one machine-parseable payload; error
   paths (unreadable Dockerfile, bad flags) also emit a single JSON object.

3. sandbox exec/run: propagate a nonzero remote exit_code to process.exitCode
   (even in --json mode) so CI and && chains detect failure. Applies to the
   normal exec path and to --follow.

4. sandbox exec --env: verified env is sent as an object under the body key
   `env` (the field the backend honors) on the direct, --shell-cmd, --follow,
   --background and --detached paths; locked with a regression test.

5. doctor --json: reconcile ok / firstFailure / summary via a single
   doctorVerdict() so they never contradict. Optional findings (MCP server,
   action-catalog drift, missing .claude/mcp.json) move to a separate warnings
   field and no longer flip ok to false or leave firstFailure null.

Adds regression tests for all five. tsc clean; 430 tests pass.
@robertohluna
robertohluna merged commit 94f5c1e into main Aug 29, 2026
2 checks passed
@robertohluna
robertohluna deleted the fix/cli-acceptance-bugs-20260829 branch August 29, 2026 23:29
robertohluna added a commit that referenced this pull request Aug 29, 2026
Follow-up to #94. The backend only accepts PUBLISHED vCPU/memory pairs
(xs 1/2048, small 2/4096, medium 4/8192, large 8/16384, xl 16/32768); disk is
a free-form floor. `templates create` previously forwarded any --cpu/--memory
combination, so an off-tier pair like --cpu 4 --memory 4gb (4 vCPU / 4 GB) was
sent and rejected by the platform with a shape-mismatch 500 after the Dockerfile
upload.

Now `templates create` resolves resources locally: a --cpu/--memory pair must
match a published shape. An off-tier pair fails fast before any API call with an
actionable message naming the nearest size (e.g. "cpu/memory 4/4096 isn't a
supported pair; nearest is medium (4 vCPU / 8192 MiB); pass --size medium").
A pair that conflicts with an explicit --size is also rejected. --disk stays
free-form and --size <name> is always safe. When no cpu/memory pins are given,
resources are still omitted so the server picks its default.

No version bump. tsc clean; 431 tests pass, incl. a new off-tier rejection test.
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.

1 participant