Skip to content

Add pkg/vmcp/cli/init.go for vMCP config scaffolding#4903

Merged
yrobla merged 1 commit intomainfrom
issue-4882
Apr 17, 2026
Merged

Add pkg/vmcp/cli/init.go for vMCP config scaffolding#4903
yrobla merged 1 commit intomainfrom
issue-4882

Conversation

@yrobla
Copy link
Copy Markdown
Contributor

@yrobla yrobla commented Apr 16, 2026

Summary

Implement Init(ctx, InitConfig) which discovers running workloads in a named ToolHive group via an injected Discoverer, renders a commented starter YAML config pre-populated with one backend entry per accessible workload, and writes the result to a file (0o600) or an io.Writer.

Workloads returning nil from GetWorkloadAsVMCPBackend are skipped with a debug log. Empty groups produce a valid YAML skeleton with backends: [].

Includes unit tests covering writer output, file output, nil-backend skipping, empty groups, discovery errors, YAML validity (loader + validator), file permissions, and input validation edge cases.

Fixes #4882

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Changes

File Change

Does this introduce a user-facing change?

Implementation plan

Approved implementation plan

Special notes for reviewers

@yrobla yrobla requested a review from Copilot April 16, 2026 15:04
@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label Apr 16, 2026
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Apr 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds vMCP config scaffolding support to the pkg/vmcp/cli package, enabling generation of a commented starter YAML config by discovering workloads in a ToolHive group and writing the result to a file or writer.

Changes:

  • Introduce Init(ctx, InitConfig) to discover group workloads via an injected workloads.Discoverer and render a commented YAML starter config.
  • Implement output routing to either an io.Writer (stdout-style) or a file written with 0o600 permissions.
  • Add unit tests for writer/file output, empty groups, nil-backend skipping, discovery errors, YAML load+validate, file permissions, and input validation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
pkg/vmcp/cli/init.go Implements workload discovery, YAML template rendering, and output writing for thv vmcp init scaffolding.
pkg/vmcp/cli/init_test.go Adds unit test coverage for init scaffolding behavior and output validity/permissions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vmcp/cli/init.go Outdated
Comment thread pkg/vmcp/cli/init.go Outdated
Comment thread pkg/vmcp/cli/init.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 70.83333% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.22%. Comparing base (5342824) to head (98a1b57).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pkg/vmcp/cli/init.go 70.83% 12 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4903      +/-   ##
==========================================
- Coverage   69.25%   69.22%   -0.04%     
==========================================
  Files         537      538       +1     
  Lines       55380    55452      +72     
==========================================
+ Hits        38354    38385      +31     
- Misses      14080    14117      +37     
- Partials     2946     2950       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yrobla yrobla requested a review from Copilot April 16, 2026 15:16
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Apr 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vmcp/cli/init.go
Comment thread pkg/vmcp/cli/init.go
Comment thread pkg/vmcp/cli/init.go
Comment thread pkg/vmcp/cli/init.go Outdated
@yrobla yrobla requested a review from Copilot April 16, 2026 15:27
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Apr 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vmcp/cli/init.go Outdated
Comment thread pkg/vmcp/cli/init.go Outdated
Comment thread pkg/vmcp/cli/init_test.go Outdated
Comment thread pkg/vmcp/cli/init.go Outdated
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Apr 16, 2026
Comment thread pkg/vmcp/cli/init.go Outdated
Base automatically changed from issue-4879 to main April 17, 2026 07:10
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/M Medium PR: 300-599 lines changed labels Apr 17, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@yrobla yrobla requested review from Copilot and jerm-dro April 17, 2026 07:59
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 17, 2026
@github-actions github-actions Bot dismissed their stale review April 17, 2026 07:59

PR size has been reduced below the XL threshold. Thank you for splitting this up!

@github-actions
Copy link
Copy Markdown
Contributor

✅ PR size has been reduced below the XL threshold. The size review has been dismissed and this PR can now proceed with normal review. Thank you for splitting this up!

Implement Init(ctx, InitConfig) which discovers running workloads in a
named ToolHive group via an injected Discoverer, renders a commented
starter YAML config pre-populated with one backend entry per accessible
workload, and writes the result to a file (0o600) or an io.Writer.

Workloads returning nil from GetWorkloadAsVMCPBackend are skipped with
a debug log. Empty groups produce a valid YAML skeleton with backends: [].

Includes unit tests covering writer output, file output, nil-backend
skipping, empty groups, discovery errors, YAML validity (loader +
validator), file permissions, and input validation edge cases.

Closes #4882
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Apr 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

pkg/vmcp/cli/init.go:222

  • When writing to an arbitrary io.Writer, Write is allowed to return a short write with a nil error. Currently the code ignores the returned byte count, so it could silently truncate output. Consider using io.Copy from a bytes.Reader (or explicitly checking n == len(content) and returning io.ErrShortWrite otherwise).
	return nil
}


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vmcp/cli/init_test.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vmcp/cli/init.go
@yrobla yrobla merged commit ee988f3 into main Apr 17, 2026
49 checks passed
@yrobla yrobla deleted the issue-4882 branch April 17, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add init.go to pkg/vmcp/cli/ for config scaffolding

5 participants