Skip to content

refactor(pro): share host command wiring - #1542

Merged
skevetter merged 1 commit into
mainfrom
refactor/pro-share-host-command-wiring
Oct 18, 2026
Merged

skevetter merged 1 commit into
mainfrom
refactor/pro-share-host-command-wiring

Conversation

@skevetter

@skevetter skevetter commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds host command wiring helpers in cmd/pro/proutil: AddHostFlag, HostRunE, WithHostCompletion, MarkAgentExecuted.
  • Migrates health, check-update, self, version, update-provider, daemon status|netcheck|start, project list, template list (host flag only), cluster list (host flag only).
  • Removes five //nolint:dupl directives and two //nolint:goconst directives made unnecessary by the helpers.

Why

Each host-scoped factory repeated the same flag, env binding, required-flag, completion, and agent-executed annotation code. Sharing it keeps the wiring in one place.

Validation

  • Behaviour: throwaway dumper of usage, short, hidden, flags, defaults, annotations, and completion directives for all 11 factories, before vs after. Identical (158 lines).
  • mise run cli:format: applied.
  • mise run cli:lint:ci: 0 issues.
  • golangci-lint run --new-from-rev=origin/main ./cmd/... ./pkg/...: 0 issues on darwin, linux; ./cmd/pro/... 0 issues on windows.
  • Windows ./pkg/...: typecheck fails in pkg/extract/extract_test.go (syscall.Stat_t). Pre-existing on origin/main; this PR does not touch pkg/extract.
  • go build ./...: pass on darwin, linux, windows.
  • go test ./cmd/pro/...: pass, including new proutil tests.

CodeRabbit CLI

coderabbit review --agent --committed against origin/main merge base: completed, 0 findings, 13 files reviewed.

Auto-merge

Within policy: 12 modified files plus one new test file, 126 insertions and 293 deletions in non-test code, no go.mod changes, no lint disabled, no new //nolint.

Summary by CodeRabbit

  • Improvements
    • Host-based Pro commands now handle host selection and execution consistently.
    • Host flags continue to support required values, environment variables, and command completion.
    • Agent-executed status is applied consistently across applicable commands.
  • Tests
    • Added coverage for host selection, configuration forwarding, resolution errors, and agent-executed status.

@skevetter skevetter added the auto-refactor Automated refactor PR label Oct 18, 2026
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e45e1970-d6ff-447a-ac0c-1b3d96de5045
📥 Commits

Reviewing files that changed from the base of the PR and between db85eb5 and 5a8ebc8.

📒 Files selected for processing: 13
  • cmd/pro/check_update.go
  • cmd/pro/cluster/list.go
  • cmd/pro/daemon/netcheck.go
  • cmd/pro/daemon/start.go
  • cmd/pro/daemon/status.go
  • cmd/pro/health.go
  • cmd/pro/project/list.go
  • cmd/pro/proutil/proutil.go
  • cmd/pro/proutil/proutil_test.go
  • cmd/pro/self.go
  • cmd/pro/template/list.go
  • cmd/pro/update_provider.go
  • cmd/pro/version.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Walkthrough

Pro commands now use shared helpers for host resolution, host flag configuration, optional completion, and agent-executed annotations. Tests cover host flag behavior, execution-time resolution, error handling, and annotation preservation.

Changes: Host command setup

Layer / File(s) Summary
Shared host command helpers
cmd/pro/proutil/proutil.go, cmd/pro/proutil/proutil_test.go
Adds helpers for host-based execution, required host flag setup, optional completion, and agent-executed annotations. Tests cover flag values, provider resolution, errors, and root annotations.
Pro command integration
cmd/pro/check_update.go, cmd/pro/cluster/list.go, cmd/pro/daemon/*, cmd/pro/health.go, cmd/pro/project/list.go, cmd/pro/self.go, cmd/pro/template/list.go, cmd/pro/update_provider.go, cmd/pro/version.go
Command constructors replace inline provider resolution and host flag setup with shared helpers. Daemon commands also use shared completion and annotation helpers where applicable.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 5a8eb

The shared host-command wiring has no identified behavior change that needs correction before merge.

Security architecture risk: ⚪ Minimal · up to 5a8eb

The refactor preserves host selection, required-input handling, and failure behavior. No introduced or increased security exposure was identified in the migrated commands.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The shared helper increases the number of commands depending on one wiring implementation, but does not itself expand execution beyond the caller-selected configured host/provider or add cross-host dispatch. Downstream operation authority remains that of the existing command callbacks.

Trust Boundaries and Controls

  • observed — User-controlled host input still passes through the existing configuration and provider-resolution path. ProviderFromHost loads the configured host instance, finds its provider, and accepts proxy or daemon providers before command execution proceeds; the refactor does not bypass this selection check.

Resilience and Maintainability Implications

  • observed — The execution marker remains command-tree state set before host-scoped execution, with existing annotations preserved. It is not cleared after execution failure or cancellation, but that lifecycle behavior already existed in the replaced handlers and is not a new rollback or authority regression.
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately and concisely describes the main change: introducing shared host command wiring for pro commands.
Docstring Coverage Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 13 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 5a8ebc8
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6ad4807ef45996b6f3fae325

@netlify

netlify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 5a8ebc8
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6ad4807ed32bc7c5fc5de9b1

@skevetter
skevetter marked this pull request as ready for review October 18, 2026 09:05
@mergify

mergify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@skevetter
skevetter merged commit c5971af into main Oct 18, 2026
111 checks passed
@skevetter
skevetter deleted the refactor/pro-share-host-command-wiring branch October 18, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-refactor Automated refactor PR size/xl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant