Skip to content

Conversation

@aavetis
Copy link

@aavetis aavetis commented Feb 10, 2026

Description

Aligns the agent frontmatter JSON schema with the VS Code Custom Agents spec deltas described in #425, and updates the repo's schema validator so the new schema constraints are enforced.

Issue #425 Requirements (Checklist)

  • Add missing fields to agent-frontmatter.schema.json: agents, user-invokable, disable-model-invocation
  • Fix model type to allow string OR array of strings
  • Make handoffs.prompt optional
  • Add handoffs.model (optional string)
  • Preserve HVE-Core specific maturity field

Implementation Notes

  • Test-JsonSchemaValidation now supports the schema constructs required for this issue (oneOf, nested object with required/properties, and array.items).
  • additionalProperties is still not enforced by the validator (documented), consistent with prior behavior.

Testing

Ran locally:

  • npm run lint:frontmatter
  • npm run lint:ps
  • npm run test:ps
  • npm run spell-check
  • Validated all agents with schema validation enabled:
    • pwsh -NoProfile -Command "& scripts/linting/Validate-MarkdownFrontmatter.ps1 -WarningsAsErrors -EnableSchemaValidation -Files (Get-ChildItem -Path .github/agents -Filter *.agent.md -File | Select-Object -ExpandProperty FullName)"

Fixes #425

Notes

  • Adds dependency-pinning-artifacts/ to .gitignore since it is generated by the dependency pinning scan script during local runs and can otherwise leave the working tree dirty.

Copilot AI review requested due to automatic review settings February 10, 2026 17:00
@aavetis aavetis requested a review from a team as a code owner February 10, 2026 17:00
@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.75%. Comparing base (67585f5) to head (2bf78d9).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #469      +/-   ##
==========================================
+ Coverage   83.41%   83.75%   +0.33%     
==========================================
  Files          20       20              
  Lines        3510     3583      +73     
==========================================
+ Hits         2928     3001      +73     
  Misses        582      582              
Flag Coverage Δ
pester 83.75% <100.00%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
scripts/linting/Validate-MarkdownFrontmatter.ps1 74.23% <100.00%> (+8.92%) ⬆️

... and 1 file with indirect coverage changes

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

Copy link
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

Updates the repo’s agent frontmatter JSON schema to match VS Code Custom Agents spec deltas from #425, and extends the PowerShell schema validator to enforce the newly needed schema constructs during frontmatter linting.

Changes:

  • Expanded agent-frontmatter.schema.json with agents, user-invokable, disable-model-invocation, handoffs.model, and corrected model to allow string or string-array.
  • Enhanced Test-JsonSchemaValidation to support oneOf and nested object/array.items validation patterns used by repo schemas.
  • Added unit tests for oneOf and nested object/array validation scenarios.

Reviewed changes

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

Show a summary per file
File Description
scripts/tests/linting/Validate-MarkdownFrontmatter.Tests.ps1 Adds unit tests covering oneOf and nested object/array schema validation behavior.
scripts/linting/schemas/agent-frontmatter.schema.json Aligns agent frontmatter schema fields and types with the VS Code spec deltas (while preserving maturity).
scripts/linting/Validate-MarkdownFrontmatter.ps1 Implements validator support for oneOf and nested object/array validation patterns used by the updated schema.
.gitignore Ignores locally generated dependency-pinning artifacts directory.
.cspell.json Adds “invokable” to spelling allowlist.

@aavetis aavetis marked this pull request as draft February 10, 2026 17:16
- Address Copilot review: update validation coverage docs and avoid array += in loops

- Fix array conversion to preserve single-item arrays

- Add tests to cover oneOf + nested object/array conversion paths (Codecov patch coverage)
@aavetis aavetis marked this pull request as ready for review February 10, 2026 17:35
Copilot AI review requested due to automatic review settings February 10, 2026 17:35
Copy link
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 4 out of 5 changed files in this pull request and generated 3 comments.

Comment on lines 369 to +407
try {
if ($SchemaContent.required) {
foreach ($requiredField in $SchemaContent.required) {
if (-not $Frontmatter.ContainsKey($requiredField)) {
$errors.Add("Missing required field: $requiredField")
function ConvertTo-HashTable {
<#
.SYNOPSIS
Converts a PSCustomObject or hashtable to a hashtable recursively.
#>
[CmdletBinding()]
[OutputType([hashtable])]
param(
[Parameter(Mandatory = $true)]
[ValidateScript({ $_ -is [hashtable] -or $_ -is [pscustomobject] })]
[object]$InputObject
)

function ConvertTo-ObjectArray {
<#
.SYNOPSIS
Converts an enumerable to an object array, converting nested objects to hashtables.
#>
[CmdletBinding()]
[OutputType([object[]])]
param(
[Parameter(Mandatory = $true)]
[System.Collections.IEnumerable]$Enumerable
)

$list = [System.Collections.Generic.List[object]]::new()
foreach ($item in $Enumerable) {
if ($item -is [pscustomobject] -or $item -is [hashtable]) {
$list.Add((ConvertTo-HashTable -InputObject $item))
}
else {
$list.Add($item)
}
}

# Prevent PowerShell from unrolling single-element arrays when used in expressions/assignments.
return ,$list.ToArray()
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Test-JsonSchemaValidation defines helper functions (ConvertTo-HashTable, Test-ValueAgainstSchema, and the nested ConvertTo-ObjectArray) inside the function body. Since this validator is called per-file, repeatedly redefining these functions can add noticeable overhead when validating many markdown files. Consider moving these helpers to script scope / module scope (or caching them) so they’re defined once per script load rather than once per invocation.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings February 10, 2026 19:02
- Align disable-model-invocation description with microsoft#425/VS Code intent

- Aggregate oneOf mismatch errors across subschemas for stable, actionable diagnostics
Copy link
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 4 out of 5 changed files in this pull request and generated 1 comment.

Exclude IDictionary/hashtable from array type detection to avoid false passes and confusing item errors.
Copy link
Contributor

@katriendg katriendg left a comment

Choose a reason for hiding this comment

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

Thank you so much for picking up an open issue and addressing this @aavetis!

Really appreciate your work on this. Love the code coverage result as well, neat!
I have a few minor comments, if you could please review those? For the rest I have no other comments and we look forward to being able to merge this one in.

Thanks again and hope to see you contribute in the future.

return $localErrors.ToArray()
}

# Enum validation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we move the Enum validation to after the type checks? Type checking before will provide more accurate information and if type is correct then the enum check is valuable.
So just move the block and add a final return $localErrors.ToArray() for the function to return.

$result = Test-JsonSchemaValidation -Frontmatter $frontmatter -SchemaContent $script:NestedSchema
$result.IsValid | Should -BeTrue
}

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could you add one Rejects any non "*" string values explicitly?

foreach ($sub in $Schema.oneOf) {
$subErrs = Test-ValueAgainstSchema -Value $Value -Schema $sub -Path $Path
if ($subErrs.Count -eq 0) {
$passCount++
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: consider breaking once the result hits 2 and becomes invalid, so we don't need to further evaluate:

Suggested change
$passCount++
$passCount++
if ($passCount -gt 1) { break }

@WilliamBerryiii
Copy link
Member

@aavetis - once the code comments are resolved, I'll get this approved and merged in. Thanks for the contribution!!!

@katriendg katriendg added this to the v2.4.0 milestone Feb 12, 2026
Copilot AI review requested due to automatic review settings February 13, 2026 01:51
Copy link
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 4 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines +278 to +279
- oneOf: Supported (exactly one subschema must match)
- object: Supported for required/properties/items patterns used in repo schemas
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The docblock’s “Limitations” section lists oneOf as a limitation while also stating it’s supported. Consider moving oneOf out of “Limitations” (or rewording the section) to avoid contradictory documentation for the validator’s capabilities.

Suggested change
- oneOf: Supported (exactly one subschema must match)
- object: Supported for required/properties/items patterns used in repo schemas

Copilot uses AI. Check for mistakes.
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.

fix(scripts): add missing fields and fix types in agent-frontmatter.schema.json

4 participants