Skip to content

Fix coldbox ai refresh custom-skill manifest crash and preserve AGENTS.md content outside managed markers#71

Merged
lmajano merged 1 commit into
developmentfrom
copilot/fix-coldbox-ai-refresh-issue
May 14, 2026
Merged

Fix coldbox ai refresh custom-skill manifest crash and preserve AGENTS.md content outside managed markers#71
lmajano merged 1 commit into
developmentfrom
copilot/fix-coldbox-ai-refresh-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 14, 2026

coldbox ai refresh could crash when syncing skills-custom due to invalid closure scope usage in SkillManager. It could also overwrite user-authored AGENTS.md content when the managed marker block was repositioned.

  • Custom skill sync crash fix (SkillManager.refresh)

    • Replaced closure access of arguments.manifest with the locally scoped manifest struct during custom-skill removal/sync.
    • Eliminates Lucee runtime errors when iterating skills-custom entries.
  • Agent file merge hardening (AgentRegistry.mergeUserContent)

    • Updated merge logic to preserve user-authored content on both sides of the managed marker block:
      • content before <!-- COLDBOX-CLI:START -->
      • content after <!-- COLDBOX-CLI:END -->
    • Refresh now replaces only the managed section when a valid marker pair exists.
  • Behavioral impact

    • coldbox ai refresh now safely picks up new/deleted custom skills without manifest-scope exceptions.
    • User-customized AGENTS.md remains intact outside the CLI-managed section, even if the marker block is moved lower in the file.
// before (inside closure): invalid in Lucee closure scope
var alreadyInManifest = !arguments.manifest.customSkills
	.filter( ( s ) => s.name == dirName )
	.isEmpty()

// after: uses surrounding function scope safely
var alreadyInManifest = !manifest.customSkills
	.filter( ( s ) => s.name == dirName )
	.isEmpty()

@lmajano lmajano marked this pull request as ready for review May 14, 2026 20:57
Copilot AI review requested due to automatic review settings May 14, 2026 20:57
@lmajano lmajano merged commit 5558e7b into development May 14, 2026
1 check passed
@lmajano lmajano deleted the copilot/fix-coldbox-ai-refresh-issue branch May 14, 2026 20:57
Copy link
Copy Markdown

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

This PR improves the reliability of coldbox ai refresh by fixing a Lucee closure-scope crash during custom-skill syncing and by hardening the agent file merge logic to preserve user-authored content outside the CLI-managed marker block.

Changes:

  • Fixes Lucee closure scoping in SkillManager.refresh() by using the function-scoped manifest reference inside each()/filter() closures.
  • Updates AgentRegistry.mergeUserContent() to preserve content both before <!-- COLDBOX-CLI:START --> and after <!-- COLDBOX-CLI:END --> when refreshing agent files.
  • Updates inline documentation to reflect the new marker-pair behavior.

Reviewed changes

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

File Description
models/SkillManager.cfc Uses function-scoped manifest inside closures to prevent Lucee runtime errors when syncing/removing skills-custom entries.
models/AgentRegistry.cfc Reworks merge logic to preserve user content on both sides of the managed marker block during refresh.

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

Comment thread models/AgentRegistry.cfc
var newStartPos = findNoCase( startMarker, newContent )
var newEndPos = findNoCase( endMarker, newContent )
if ( !newStartPos || !newEndPos || newEndPos <= newStartPos ) {
return newContent & userContentAfterManaged
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.

3 participants