Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

The codebase had 250+ instances of manual string manipulation for workflow filename transformations (.md.lock.yml, campaign specs, etc.) scattered across files, making maintenance error-prone and inconsistent. Additionally, file type detection logic using strings.HasSuffix() was duplicated throughout the codebase.

Changes

Created centralized helpers in pkg/stringutil/identifiers.go:

Filename Transformations:

  • MarkdownToLockFile() - .md.lock.yml
  • LockFileToMarkdown() - .lock.yml.md
  • CampaignSpecToOrchestrator() - .campaign.md.campaign.g.md
  • CampaignOrchestratorToLockFile() - .campaign.g.md.campaign.lock.yml
  • CampaignSpecToLockFile() - .campaign.md.campaign.lock.yml

File Type Detection:

  • IsCampaignSpec() - Detects campaign specification files (.campaign.md)
  • IsCampaignOrchestrator() - Detects campaign orchestrator files (.campaign.g.md)
  • IsAgenticWorkflow() - Detects agentic workflow files (.md excluding campaigns)
  • IsLockFile() - Detects compiled lock files (.lock.yml)
  • IsCampaignLockFile() - Detects campaign lock files (.campaign.lock.yml)

Replaced patterns across 119 files:

  • strings.TrimSuffix(path, ".md") + ".lock.yml"stringutil.MarkdownToLockFile(path)
  • strings.Replace(path, ".md", ".lock.yml", 1)stringutil.MarkdownToLockFile(path)
  • Campaign-specific transformations → dedicated helpers

Examples

Filename Transformation - Before:

lockFile := strings.TrimSuffix(markdownPath, ".md") + ".lock.yml"
if strings.HasSuffix(markdownPath, ".campaign.g.md") {
    baseName := strings.TrimSuffix(markdownPath, ".campaign.g.md")
    lockFile = baseName + ".campaign.lock.yml"
}

Filename Transformation - After:

var lockFile string
if strings.HasSuffix(markdownPath, ".campaign.g.md") {
    lockFile = stringutil.CampaignOrchestratorToLockFile(markdownPath)
} else {
    lockFile = stringutil.MarkdownToLockFile(markdownPath)
}

File Type Detection - Before:

if strings.HasSuffix(path, ".campaign.md") {
    // handle campaign spec
}

File Type Detection - After:

if stringutil.IsCampaignSpec(path) {
    // handle campaign spec
}

All helpers include comprehensive tests with round-trip validation and exclusivity testing to ensure file types are correctly distinguished.

Original prompt

Refactor and centralize all the workflow filename manipulator code into helper functions in .go

Search for any ".lock.yml", ".md" string literals, look for workflow name to id, id to filename etc...


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits January 8, 2026 05:07
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…nctions

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor and centralize workflow filename manipulator code Centralize workflow filename manipulation into helper functions Jan 8, 2026
Copilot AI requested a review from pelikhan January 8, 2026 05:29
@pelikhan
Copy link
Contributor

pelikhan commented Jan 8, 2026

@copilot also refactor helpers to determine if a file is a campaign or a compiled agentic campaign workflow or a agentic workflow or a lock file

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 8, 2026

@copilot also refactor helpers to determine if a file is a campaign or a compiled agentic campaign workflow or a agentic workflow or a lock file

Added 5 file type detection helpers in commit fcc9f41:

  • IsCampaignSpec(path) - Detects .campaign.md files
  • IsCampaignOrchestrator(path) - Detects .campaign.g.md files
  • IsAgenticWorkflow(path) - Detects .md files (excluding campaigns)
  • IsLockFile(path) - Detects .lock.yml files
  • IsCampaignLockFile(path) - Detects .campaign.lock.yml files

All helpers include comprehensive tests with exclusivity validation to ensure file types are correctly distinguished.

Copilot AI changed the title Centralize workflow filename manipulation into helper functions Centralize workflow filename manipulation and file type detection into helper functions Jan 8, 2026
@pelikhan pelikhan marked this pull request as ready for review January 8, 2026 05:50
@pelikhan pelikhan merged commit 5af45ab into main Jan 8, 2026
113 checks passed
@pelikhan pelikhan deleted the copilot/refactor-workflow-filemanipulator branch January 8, 2026 05:52
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