Skip to content

[skills] Add skills to create ports and patches#51187

Draft
vicroms wants to merge 13 commits intomicrosoft:masterfrom
vicroms:skills/create-port
Draft

[skills] Add skills to create ports and patches#51187
vicroms wants to merge 13 commits intomicrosoft:masterfrom
vicroms:skills/create-port

Conversation

@vicroms
Copy link
Copy Markdown
Member

@vicroms vicroms commented Apr 15, 2026

Adds two AI skills to assist with creation of new ports.

The create-port skill takes a GitHub URL and infers any necessary information to generate a port.

  • Detects build system and use appropriate vcpkg helpers (vcpkg-cmake, vcpkg-make, etc.)
  • De-vendors dependencies by patching to use vcpkg versions or create ports for ones not available in vcpkg yet.
  • Follows vcpkg maintainer guidelines.

The create-patch skill was made to teach Copilot how to properly generate patches using a temporary Git repository, otherwise, I found that Copilot had a strong preference for using vcpkg_replace_string or generating patches without proper code point references.

I tested only with GitHub libraries, but the AI might be smart enough to figure when to use other helpers without explicit instruction on the skill.

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

Comment thread .github/skills/create-patches/SKILL.md Outdated
Comment thread .github/skills/create-patches/SKILL.md Outdated
Comment thread .github/skills/create-patches/SKILL.md Outdated
Comment thread .github/skills/create-port/templates/complex-build.portfile.cmake Outdated
@BillyONeal BillyONeal changed the title [skils] Add skills to create ports and patches [skills] Add skills to create ports and patches Apr 15, 2026
Comment thread .github/skills/create-port/templates/cmake-library.portfile.cmake Outdated
@BillyONeal
Copy link
Copy Markdown
Member

I tested only with GitHub libraries, but the AI might be smart enough to figure when to use other helpers without explicit instruction on the skill.

Is there some way we can document how to test this so that if/when we change it in the future we at least have a vague idea what to not break?

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@BillyONeal BillyONeal marked this pull request as draft April 15, 2026 23:11
vicroms and others added 7 commits April 27, 2026 12:23
Convert all 12 files under .github/skills/ from CRLF to LF.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Place patches at port root instead of patches/ subdirectory
- Remove --debug flag from first-attempt build commands
- Add topic branch workflow to avoid upstream merge conflicts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Enhanced 'Example Analysis Results' table with gqlxy-server example showing version-date usage for projects without official releases
- Added new 'Version-Date Guidance' section explaining when and how to use version-date schema
- Clarified that semantic versions should never be used for unreleased projects
- Provided command to find commit dates for version-date field
- Updated success indicators to include version scheme verification

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Enhanced CMake target verification with common mismatch examples
- Added ALIAS target creation pattern for target name mismatches
- Documented proper patch file best practices (naming, line endings, context)
- Expanded component disabling strategy with BUILD_SAMPLES pattern
- Added resource exhaustion caveat for constrained build environments
- New pattern: Creating CMake target aliases for upstream compatibility
- Comprehensive patch creation workflows with real-world examples

These learnings reflect issues encountered while testing gqlxy-server port:
- CMake target naming mismatches (gqlxy::core vs gqlxy::gqlxy_core)
- Memory exhaustion during sample/test linking
- Patch application failures due to line endings and context matching

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fixed 8 files missing trailing newlines
- Ensures compliance with Unix text file conventions
- Applies to SKILL.md files and reference/template files
- No content changes, formatting only

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
vicroms and others added 4 commits April 27, 2026 15:26
Updated create-port SKILL:
- New 'Testing Ports After Packaging' section with comprehensive test workflows
- Feature testing patterns for individual and combined features
- CMake integration verification
- Resource constraint guidance for debug builds with heavy dependencies
- Testing checklist for production-ready ports

Updated create-patches SKILL:
- New 'Scenario 4: Feature-Related Patches' section
- Pattern for adding CMake feature options via patches
- Integration with vcpkg_check_features helper

Rationale: Session testing revealed importance of post-package testing,
proper feature handling with vcpkg_check_features, and understanding resource
constraints on systems with memory-intensive dependencies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove BUILD_SHARED_LIBS from portfile templates (handled by vcpkg toolchain)
- Make usage files optional - vcpkg generates them heuristically
- Add documentation cleanup to remove /share/doc by default
- Clarify usage files should not include #include statements
- Update templates and references to reflect minimal, focused portfile approach
- Add vcpkg_fixup_pkgconfig() to standard template
- Update best practices documentation

These changes ensure ports follow vcpkg conventions and stay lean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Move branch workflow section to top of document for immediate visibility
- Add ⚠️ IMPORTANT warning label
- Include clear do-not instructions
- Highlight benefits of topic branch workflow
- Reference workflow instructions from later sections

This ensures users understand the required branch workflow before starting
port creation and helps prevent accidental commits to master branch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vicroms vicroms marked this pull request as ready for review April 30, 2026 21:32
vcpkg's patch utility requires Unix-style LF line endings, not Windows CRLF:
```powershell
# PowerShell: Normalize to LF only
$text = [System.IO.File]::ReadAllText('path/to/file.patch')
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.

I'm not sure this is correct: if the patched repo itself has CRLFs there will be CRLFs in the patch file to my understanding, and this will be damage those patches.

Can we tell it to use git diff --output or similar to make the patches rather than trying to fix them up after the fact like this?

Comment on lines +202 to +203
# Test patch application (non-destructive)
git apply path/to/patch.patch
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.

git apply is not "non-destructive"


**Debugging CMake Targets:**
To verify what targets a vcpkg port actually exports:
```powershell
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.

Should there be bash/zsh ones for the non-Windows platforms? (It's ok if the answer is no)

Comment on lines +342 to +349
# Before: Unconditionally builds samples
if(PROJECT_IS_TOP_LEVEL)
add_subdirectory(samples)
endif()

# After: Add option to disable
option(BUILD_SAMPLES "Build sample applications" ON)
if(PROJECT_IS_TOP_LEVEL AND BUILD_SAMPLES)
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.

IMO we should only patch in an option like this if we are considering submitting the patch upstream. A much shorter patch would be just

-if(PROJECT_IS_TOP_LEVEL)
+if(0)

which has the same effect without needing OPTIONS below.

**Why This Pattern Matters:**
- Samples/tests often consume excessive memory during linking on constrained environments
- Disabling them via CMake is cleaner than post-build deletion (no CMake errors from missing directories)
- Users can still enable if needed via CMake options in consumer projects
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.

No they can't

```bash
# Local testing
cd source-directory
git apply ../ports/package-name/001-fix-build.patch
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.

The source directory, typically buildtrees/<port>/src/aasdfasdf-asdfasdfas.clean is not ../ to "ports".

Comment on lines +447 to +454
The upstream project expects a `BUILD_STANDALONE_SERVER` option. Create a patch adding this:

```diff
@@ -42,8 +42,11 @@ endif()

# Server components
-if(BUILD_SERVER)
+option(BUILD_STANDALONE_SERVER "Build standalone GraphQL server" ON)
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.

How can upstream "expect" it if we are patching it in ourselves?

Comment on lines +159 to +161
"docs": {
"description": "Build documentation"
}
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.

It looks like elsewhere we told it to patch building these out entirely but here it's suggesting to add "docs" and "tests" as features. Ditto below.


**vcpkg.json** - Package manifest with auto-detected metadata:
```json
{
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.

Should we vcpkg format-manifest this content?

Comment on lines +804 to +806
vcpkg install "package-name[feature1]"
vcpkg install "package-name[feature2]"
vcpkg install "package-name[feature1,feature2]"
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.

vcpkg x-test-features package-name --ci-feature-baseline scripts/ci.feature.baseline.txt


```cmake
# test-consumer/CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
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.

We should probably use latest at time of writing 3.23 here

Comment on lines +836 to +837
- [ ] Each feature can be installed individually
- [ ] Multiple features can be combined: `[feat1,feat2]`
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.

These two checkboxes x-test-features will do for you.

3. **Monitor CI** for platform-specific issues and respond to feedback
4. **Update documentation** if special integration steps are required
---
name: create-port
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.

There's nothing about pkgconfig in here. Should there be?

)
vcpkg_cmake_install()

vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/package-name)
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.

Should we explain how/when to use vcpkg_cmake_config_fixup and/or vcpkg_fixup_pkgconfig? (For example, the former should only run if the thing installs a CMake config, and the latter should run only if it installs pkgconfig)

@BillyONeal BillyONeal marked this pull request as draft May 1, 2026 20:21
@vicroms
Copy link
Copy Markdown
Member Author

vicroms commented May 3, 2026

I'm working on evaluations for the skills (see #51513), that should let us measure whether these skills actually improve the AI and give us a base level of confidence that the output is correct.

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