Skip to content

Add fix codemod to migrate safe-outputs message ET suffix placeholders to AI credits suffix - #37685

Merged
pelikhan merged 3 commits into
mainfrom
copilot/add-codemod-replace-message-suffix
Jun 8, 2026
Merged

Add fix codemod to migrate safe-outputs message ET suffix placeholders to AI credits suffix#37685
pelikhan merged 3 commits into
mainfrom
copilot/add-codemod-replace-message-suffix

Conversation

CopilotAI commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Custom safe-outputs.messages templates still using {effective_tokens_suffix} continued to render ET-oriented footer text. This change introduces a fix codemod that rewrites those frontmatter placeholders to {ai_credits_suffix} so migrated workflows render AIC suffixes by default.

  • Codemod added

    • Introduced messages-effective-tokens-suffix-to-ai-credits-suffix.
    • Rewrites placeholder usage inside safe-outputs.messages from:
      • {effective_tokens_suffix}{ai_credits_suffix}
  • Transformation scope

    • Applies only to YAML frontmatter.
    • Targets only safe-outputs.messages entries (not unrelated fields).
    • Handles both inline scalar message values and block scalar (| / >) message bodies.
    • Preserves existing indentation, comments, and markdown body content.
  • Fix pipeline integration

    • Registered in the gh aw fix codemod registry immediately after the effective-tokens budget migration codemod to keep ET→AIC migrations ordered and coherent.
  • Example migration

    safe-outputs:
    messages:
    footer: "> [{workflow_name}]({run_url}){effective_tokens_suffix}"run-failure: | Failed run Cost: {effective_tokens_suffix}

    becomes

    safe-outputs:
    messages:
    footer: "> [{workflow_name}]({run_url}){ai_credits_suffix}"run-failure: | Failed run Cost: {ai_credits_suffix}

CopilotAIand others added 2 commits June 8, 2026 00:23
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI changed the title Add fix codemod for safe-outputs message ET suffix placeholdersAdd fix codemod to migrate safe-outputs message ET suffix placeholders to AI credits suffixJun 8, 2026
CopilotAI requested a review from pelikhanJune 8, 2026 00:25
@pelikhan
pelikhan marked this pull request as ready for review June 8, 2026 00:26
CopilotAI review requested due to automatic review settings June 8, 2026 00:26
@pelikhan
pelikhan merged commit 410eeda into mainJun 8, 2026
14 of 18 checks passed
@pelikhan
pelikhan deleted the copilot/add-codemod-replace-message-suffix branch June 8, 2026 00:26

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new gh aw fix codemod to migrate safe-outputs.messages templates that still use the legacy {effective_tokens_suffix} placeholder so they render the AI Credits suffix via {ai_credits_suffix} after the ET→AIC budget migration.

Changes:

  • Registered a new codemod (messages-effective-tokens-suffix-to-ai-credits-suffix) in the fix codemod registry immediately after effective-tokens-to-ai-credits.
  • Implemented a frontmatter-only line-transform that targets safe-outputs.messages scalar values and block scalars (| / >), replacing {effective_tokens_suffix} with {ai_credits_suffix}.
  • Added unit tests covering registry presence/order and basic formatting + block-scalar preservation.
Show a summary per file
FileDescription
pkg/cli/fix_codemods.goRegisters the new messages placeholder migration codemod in the fix registry.
pkg/cli/fix_codemods_test.goUpdates expected codemod presence and ordering to include the new codemod.
pkg/cli/codemod_messages_effective_tokens_suffix_to_ai_credits_suffix.goImplements the new codemod that rewrites {effective_tokens_suffix} to {ai_credits_suffix} inside safe-outputs.messages in frontmatter.
pkg/cli/codemod_messages_effective_tokens_suffix_to_ai_credits_suffix_test.goAdds unit tests validating the codemod metadata and transformation behavior (including block scalars).

Copilot's findings

Tip

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

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Comment on lines +145 to +155
updated := strings.ReplaceAll(line, effectiveTokensSuffixPlaceholder, aiCreditsSuffixPlaceholder)
if updated != line {
modified = true
}
result = append(result, updated)

parts := strings.SplitN(updated, ":", 2)
if len(parts) == 2 && isBlockScalarIndicator(parts[1]) {
inBlockScalar = true
blockScalarIndent = indent
}
Sign up for freeto 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

@pelikhan