Skip to content

Commit 66b2262

Browse files
committed
feat(#194): enhance agentic Copilot scaffold with identifier replacements and documentation updates
- Update design and review prompts for consistency in section naming - Introduce identifier replacement lists in scaffold content functions - Adjust documentation references to use project-specific naming conventions
1 parent b11ca6b commit 66b2262

28 files changed

Lines changed: 140 additions & 142 deletions

.github/agents/architect.agent.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ Design or reshape changes that cross public commands, private helper boundaries,
3737
## Skills to use
3838

3939
- `/powershell-module-development`
40-
- `/github-actions`
4140
- `/release-and-changelog`
41+
- `/markdown-authoring`
42+
- `/building-maintainable-code`
43+
- `/github-actions`
4244
- `/codescene-quality`
4345
- `/guiding-refactoring-with-code-health`
44-
- `/building-maintainable-code`
45-
- `/markdown-authoring`
4646

4747
## Constraints
4848

.github/agents/powershell-developer.agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Implement PowerShell command and helper changes in the NovaModuleTools style.
2525
## Inputs to inspect
2626

2727
- The relevant file in `src/public/`
28-
- Matching helpers in `src/private/build|cli|package|quality|release|scaffold|shared|update/`
28+
- Matching helpers in `src/private/`
2929
- Matching test files in `tests/`
3030
- `project.json`
3131

.github/agents/release-manager.agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Handle versioning, changelog shaping, release-flow documentation, and publish au
3030

3131
- `/release-and-changelog`
3232
- `/markdown-authoring`
33-
- `/github-actions`
3433
- `/pester-testing`
34+
- `/github-actions`
3535

3636
## Constraints
3737

scripts/build/Sync-AgenticCopilotScaffold.ps1

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -165,56 +165,29 @@ function Split-AgenticContentByCodeFence {
165165
return ,$segments.ToArray()
166166
}
167167

168-
function Invoke-AgenticInlineCodeAwareReplace {
169-
param(
170-
[Parameter(Mandatory)][string]$Text,
171-
[Parameter(Mandatory)][string]$Old,
172-
[Parameter(Mandatory)][AllowEmptyString()][string]$New
173-
)
174-
175-
$result = [System.Text.StringBuilder]::new()
176-
$isInsideInlineCode = $false
177-
$i = 0
178-
while ($i -lt $Text.Length) {
179-
$character = $Text[$i]
180-
if ($character -eq '`') {
181-
$isInsideInlineCode = -not $isInsideInlineCode
182-
[void]$result.Append($character)
183-
$i++
184-
continue
185-
}
186-
187-
if (-not $isInsideInlineCode -and $i + $Old.Length -le $Text.Length -and $Text.Substring($i, $Old.Length) -eq $Old) {
188-
[void]$result.Append($New)
189-
$i += $Old.Length
190-
continue
191-
}
192-
193-
[void]$result.Append($character)
194-
$i++
195-
}
196-
197-
return $result.ToString()
198-
}
199-
200168
function ConvertTo-AgenticScaffoldContent {
201169
param(
202170
[Parameter(Mandatory)][string]$Content,
203-
[Parameter(Mandatory)][object[]]$ReplacementList
171+
[Parameter(Mandatory)][object[]]$ReplacementList,
172+
[AllowNull()][AllowEmptyCollection()][object[]]$IdentifierReplacementList
204173
)
205174

206175
$segments = Split-AgenticContentByCodeFence -Content $Content
207176
$rebuilt = [System.Text.StringBuilder]::new()
208177
foreach ($segment in $segments) {
209-
if ($segment.Kind -eq 'Fenced') {
210-
[void]$rebuilt.Append($segment.Text)
211-
continue
178+
$segmentText = $segment.Text
179+
if ($segment.Kind -ne 'Fenced') {
180+
foreach ($replacement in $ReplacementList) {
181+
$segmentText = $segmentText.Replace([string]$replacement.Old, [string]$replacement.New)
182+
}
212183
}
213184

214-
$segmentText = $segment.Text
215-
foreach ($replacement in $ReplacementList) {
216-
$segmentText = Invoke-AgenticInlineCodeAwareReplace -Text $segmentText -Old ([string]$replacement.Old) -New ([string]$replacement.New)
185+
if ($IdentifierReplacementList) {
186+
foreach ($identifier in $IdentifierReplacementList) {
187+
$segmentText = $segmentText.Replace([string]$identifier.Old, [string]$identifier.New)
188+
}
217189
}
190+
218191
[void]$rebuilt.Append($segmentText)
219192
}
220193

@@ -251,7 +224,8 @@ function Write-AgenticMirroredFile {
251224
param(
252225
[Parameter(Mandatory)][object]$SourceFile,
253226
[Parameter(Mandatory)][string]$TargetRoot,
254-
[Parameter(Mandatory)][object[]]$ReplacementList
227+
[Parameter(Mandatory)][object[]]$ReplacementList,
228+
[AllowNull()][AllowEmptyCollection()][object[]]$IdentifierReplacementList
255229
)
256230

257231
$targetPath = Join-Path $TargetRoot ($SourceFile.RelativePath -replace '/', [System.IO.Path]::DirectorySeparatorChar)
@@ -261,7 +235,7 @@ function Write-AgenticMirroredFile {
261235
}
262236

263237
$sourceContent = Get-Content -LiteralPath $SourceFile.SourcePath -Raw
264-
$targetContent = ConvertTo-AgenticScaffoldContent -Content $sourceContent -ReplacementList $ReplacementList
238+
$targetContent = ConvertTo-AgenticScaffoldContent -Content $sourceContent -ReplacementList $ReplacementList -IdentifierReplacementList $IdentifierReplacementList
265239
Set-Content -LiteralPath $targetPath -Value $targetContent -Encoding utf8 -NoNewline
266240
}
267241

@@ -285,7 +259,8 @@ function Get-AgenticGeneratedMirrorContent {
285259
param(
286260
[Parameter(Mandatory)][string]$RootPath,
287261
[Parameter(Mandatory)][string]$SourceRelativePath,
288-
[object[]]$ReplacementList
262+
[object[]]$ReplacementList,
263+
[AllowNull()][AllowEmptyCollection()][object[]]$IdentifierReplacementList
289264
)
290265

291266
$sourcePath = Resolve-AgenticRepositoryPath -RootPath $RootPath -RelativePath $SourceRelativePath
@@ -295,10 +270,17 @@ function Get-AgenticGeneratedMirrorContent {
295270

296271
$sourceContent = Get-Content -LiteralPath $sourcePath -Raw
297272
$banner = "<!-- Generated from $SourceRelativePath by scripts/build/Sync-AgenticCopilotScaffold.ps1. Do not edit by hand. -->`n`n"
298-
$body = if ($null -eq $ReplacementList -or $ReplacementList.Count -eq 0) {
273+
$hasReplacements = $ReplacementList -and $ReplacementList.Count -gt 0
274+
$hasIdentifiers = $IdentifierReplacementList -and $IdentifierReplacementList.Count -gt 0
275+
$body = if (-not $hasReplacements -and -not $hasIdentifiers) {
299276
$sourceContent
300277
} else {
301-
ConvertTo-AgenticScaffoldContent -Content $sourceContent -ReplacementList $ReplacementList
278+
$effectiveReplacements = if ($hasReplacements) {
279+
$ReplacementList
280+
} else {
281+
@()
282+
}
283+
ConvertTo-AgenticScaffoldContent -Content $sourceContent -ReplacementList $effectiveReplacements -IdentifierReplacementList $IdentifierReplacementList
302284
}
303285

304286
return $banner + $body
@@ -309,7 +291,8 @@ function Invoke-AgenticGeneratedMirrorPlan {
309291
[Parameter(Mandatory)][string]$RootPath,
310292
[Parameter(Mandatory)][string]$ScaffoldStagingRoot,
311293
[Parameter(Mandatory)][object[]]$GeneratedMirrorList,
312-
[object[]]$ReplacementList
294+
[object[]]$ReplacementList,
295+
[AllowNull()][AllowEmptyCollection()][object[]]$IdentifierReplacementList
313296
)
314297

315298
foreach ($mirror in $GeneratedMirrorList) {
@@ -319,7 +302,7 @@ function Invoke-AgenticGeneratedMirrorPlan {
319302
}
320303

321304
if ($mirror.ScaffoldTarget) {
322-
$scaffoldContent = Get-AgenticGeneratedMirrorContent -RootPath $RootPath -SourceRelativePath $mirror.Source -ReplacementList $ReplacementList
305+
$scaffoldContent = Get-AgenticGeneratedMirrorContent -RootPath $RootPath -SourceRelativePath $mirror.Source -ReplacementList $ReplacementList -IdentifierReplacementList $IdentifierReplacementList
323306
Write-AgenticGeneratedMirrorPath -TargetRoot $ScaffoldStagingRoot -RelativeTarget $mirror.ScaffoldTarget -Content $scaffoldContent
324307
}
325308
}
@@ -358,11 +341,11 @@ function Invoke-AgenticCopilotScaffoldSync {
358341
}
359342

360343
foreach ($sourceFile in $sourceFileList) {
361-
Write-AgenticMirroredFile -SourceFile $sourceFile -TargetRoot $stagingRoot -ReplacementList $manifest.TextReplacements
344+
Write-AgenticMirroredFile -SourceFile $sourceFile -TargetRoot $stagingRoot -ReplacementList $manifest.TextReplacements -IdentifierReplacementList $manifest.IdentifierReplacements
362345
}
363346

364347
if ($manifest.ContainsKey('GeneratedMirrors') -and $manifest.GeneratedMirrors) {
365-
Invoke-AgenticGeneratedMirrorPlan -RootPath $RootPath -ScaffoldStagingRoot $stagingRoot -GeneratedMirrorList $manifest.GeneratedMirrors -ReplacementList $manifest.TextReplacements
348+
Invoke-AgenticGeneratedMirrorPlan -RootPath $RootPath -ScaffoldStagingRoot $stagingRoot -GeneratedMirrorList $manifest.GeneratedMirrors -ReplacementList $manifest.TextReplacements -IdentifierReplacementList $manifest.IdentifierReplacements
366349
}
367350

368351
if (Test-Path -LiteralPath $TargetRoot) {

scripts/build/Sync-AgenticCopilotScaffold.psd1

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
}
2828
)
2929

30+
IdentifierReplacements = @(
31+
@{
32+
Old = 'NovaModuleTools'
33+
New = '{{ProjectName}}'
34+
}
35+
@{
36+
Old = '-Nova*'
37+
New = '-{{ShortName}}*'
38+
}
39+
)
40+
3041
ExcludedPaths = @(
3142
'.github/agents/docs-site.agent.md'
3243
'.github/instructions/documentation-separation.instructions.md'
@@ -247,18 +258,10 @@
247258
Old = 'quality tooling tooling'
248259
New = 'quality tooling'
249260
}
250-
@{
251-
Old = 'NovaModuleTools'
252-
New = '{{ProjectName}}'
253-
}
254261
@{
255262
Old = '- Must not mix PowerShell cmdlet UX and `nova` CLI UX.'
256263
New = ''
257264
}
258-
@{
259-
Old = '-Nova*'
260-
New = '-{{ShortName}}*'
261-
}
262265
@{
263266
Old = ', and the `nova` CLI routing model.'
264267
New = '.'
@@ -339,5 +342,25 @@
339342
Old = '- Preserve the distinction between public PowerShell cmdlets and `% nova` CLI behavior.'
340343
New = ''
341344
}
345+
@{
346+
Old = '- For step-by-step refactoring of unhealthy files, use the `building-maintainable-code` and `guiding-refactoring-with-code-health` skills together: the first picks the right guideline, the second runs measured maintainability checks between steps.'
347+
New = '- For step-by-step refactoring of unhealthy files, use the `building-maintainable-code` for checks between steps.'
348+
}
349+
@{
350+
Old = 'CommandInfo = Get-Command -Module NovaModuleTools'
351+
New = 'CommandInfo = Get-Command -Module {{ProjectName}}'
352+
}
353+
@{
354+
Old = '- Treating maintainability 9.x as the goal. Aim for 10.0 on touched files in this repository.'
355+
New = ''
356+
}
357+
@{
358+
Old = '- `code_health_review` and `pre_commit_code_health_safeguard` from `safeguarding-ai-generated-code` before suggesting a commit'
359+
New = ''
360+
}
361+
@{
362+
Old = '- `code_health_review` paired with `guiding-refactoring-with-code-health` when iterating on a single unhealthy file'
363+
New = ''
364+
}
342365
)
343366
}

src/resources/agentic-copilot/.github/agents/architect.agent.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,16 @@ Design or reshape changes that cross public commands, private helper boundaries,
3030
- `.github/copilot-instructions.md`
3131
- `.github/prompts/design-change.prompt.md`
3232
- `.github/instructions/*.instructions.md`
33-
- `tests/ArchitectureGuardrails.Tests.ps1`
33+
- `tests/*Architecture*.Tests.ps1`
3434
- Relevant `src/public/` and `src/private/<domain>/` files
35-
- Relevant `.github/workflows/*.yml`
35+
- Relevant workflow files, when present
3636

3737
## Skills to use
3838

3939
- `/powershell-module-development`
40-
- `/github-actions`
4140
- `/release-and-changelog`
42-
43-
- `/building-maintainable-code`
4441
- `/markdown-authoring`
42+
- `/building-maintainable-code`
4543

4644
## Constraints
4745

src/resources/agentic-copilot/.github/agents/powershell-developer.agent.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Implement PowerShell command and helper changes in the {{ProjectName}} style.
2525
## Inputs to inspect
2626

2727
- The relevant file in `src/public/`
28-
- Matching helpers in `src/private/build|cli|package|quality|release|scaffold|shared|update/`
28+
- Matching helpers in `src/private/`
2929
- Matching test files in `tests/`
3030
- `project.json`
3131

@@ -44,7 +44,7 @@ Implement PowerShell command and helper changes in the {{ProjectName}} style.
4444
- Keep new or heavily changed source functions aligned with `.github/instructions/code-quality-matrix.instructions.md`: short, single-purpose, low-duplication, and split by clear responsibility unless the scope explicitly justifies otherwise.
4545
- Prefer `./scripts/build/Invoke-ScriptAnalyzerCI.ps1` and `./run.ps1` for normal analyzer loops; use direct `Invoke-ScriptAnalyzer` only for focused local checks that reuse the repository-approved settings.
4646
- Validate Nova-managed project tests through `Test-NovaBuild`; do not call `Invoke-Pester` directly.
47-
- When help files change, keep `docs/NovaModuleTools/en-US/*.md` valid for `Import-MarkdownCommandHelp`: use `New-MarkdownCommandHelp` for new files, `Update-MarkdownCommandHelp` after command-surface changes, and `Test-MarkdownCommandHelp` before handoff. A new public `src/public/*.ps1` file is not done until its matching help file exists.
47+
- When help files change, keep `docs/{{ProjectName}}/en-US/*.md` valid for `Import-MarkdownCommandHelp`: use `New-MarkdownCommandHelp` for new files, `Update-MarkdownCommandHelp` after command-surface changes, and `Test-MarkdownCommandHelp` before handoff. A new public `src/public/*.ps1` file is not done until its matching help file exists.
4848

4949
## Definition of done
5050

src/resources/agentic-copilot/.github/agents/release-manager.agent.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ Handle versioning, changelog shaping, release-flow documentation, and publish au
2222
- `CHANGELOG.md`
2323
- `project.json`
2424
- `.github/pull_request_template.md`
25-
- `.github/workflows/Publish.yml`
25+
- release workflow files, when present
2626
- Relevant package, release, and publish tests
2727
- `README.md` / `CONTRIBUTING.md`
2828

2929
## Skills to use
3030

3131
- `/release-and-changelog`
3232
- `/markdown-authoring`
33-
- `/github-actions`
3433
- `/pester-testing`
3534

3635
## Constraints

src/resources/agentic-copilot/.github/agents/reviewer.agent.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Review changes for correctness, maintainability, test coverage, workflow safety,
1717
- When the review scope is genuinely ambiguous (for example which subset of files to focus on, or whether a borderline behavior change is intentional), ask one clarifying question before proceeding instead of guessing.
1818
- Treat quality tooling maintainability and changed-code coverage results as release-blocking signals unless risk is accepted explicitly.
1919
- If local quality tooling is unavailable, continue the review with normal validation and rely on PR/CI as the effective quality tooling gate.
20-
- Check whether project docs preserve the CLI-vs-cmdlet separation when `docs/*.html` or help markdown changed.
20+
- Check whether project docs preserve the CLI-vs-cmdlet separation when project docs or help markdown changed.
2121
- Check that Nova projects still use generated `dist/` module files instead of hand-written source `.psm1` or module `.psd1` files.
2222
- Check changed PowerShell code, tests, and examples against `project.json` `Manifest.PowerShellHostVersion`; flag PowerShell 7.x-only constructs in projects that target `5.1` unless the change explicitly adds guarded compatibility handling.
23-
- Check that public commands/classes have matching valid PlatyPS-compatible help and that new source files have source-mirrored tests. Flag help files under `docs/NovaModuleTools/en-US/` that look like plain Markdown, break the required PlatyPS section order, or would fail `Test-MarkdownCommandHelp` / `Import-MarkdownCommandHelp`.
23+
- Check that public commands/classes have matching valid PlatyPS-compatible help and that new source files have source-mirrored tests. Flag help files under `docs/{{ProjectName}}/en-US/` that look like plain Markdown, break the required PlatyPS section order, or would fail `Test-MarkdownCommandHelp` / `Import-MarkdownCommandHelp`.
2424
- Flag any new public entry point that does not add its matching help file in the same change.
2525
- Check analyzer changes and PowerShell validation flow against `.github/instructions/psscriptanalyzer.instructions.md`. Flag direct `Invoke-ScriptAnalyzer` usage that bypasses repository-approved settings or wrapper semantics without a clear reason.
2626
- Review changed `src/**/*.ps1` against `.github/instructions/code-quality-matrix.instructions.md` and `tests/**/*.ps1` against `.github/instructions/testing-policy.instructions.md`; flag new or heavily changed code that ignores those maintainability rules without a clear, explicit reason.
@@ -35,17 +35,16 @@ Review changes for correctness, maintainability, test coverage, workflow safety,
3535

3636
- The change diff
3737
- `.github/pull_request_template.md`
38-
- Relevant files in `src/`, `tests/`, `docs/`, and `.github/workflows/`
38+
- Relevant files in `src/`, `tests/`, `docs/`, and workflow files, when present
3939
- `README.md`, `CONTRIBUTING.md`, and `CHANGELOG.md` when touched
4040

4141
## Skills to use
4242

4343
- `/building-maintainable-code`
44-
- `/docs-site`
44+
- `/documentation`
4545
- `/markdown-authoring`
4646
- `/pester-testing`
4747
- `/release-and-changelog`
48-
- `/github-actions`
4948

5049
## Constraints
5150

src/resources/agentic-copilot/.github/agents/test-engineer.agent.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ Improve or maintain the repository's Pester coverage, coverage-gate behavior, an
2424

2525
- `tests/*.Tests.ps1`
2626
- `tests/*TestSupport.ps1`
27-
- `scripts/build/ci/Invoke-NovaModuleToolsCI.ps1`
28-
- `.github/workflows/Tests.yml`
27+
- repository CI helper scripts, when present
28+
- workflow files, when present
2929
- quality tooling findings when available
3030

3131
## Skills to use
3232

3333
- `/pester-testing`
3434

3535
- `/building-maintainable-code`
36-
- `/github-actions`
3736

3837
## Constraints
3938

0 commit comments

Comments
 (0)