-
Notifications
You must be signed in to change notification settings - Fork 361
[aw-compat] Fix Serena codemod output for nested engine config and stale gh-aw source pins #28080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
5459cc8
100563a
b44c15f
ab5bd4e
a0a3471
c6f0ecf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -21,24 +21,8 @@ func getSerenaToSharedImportCodemod() Codemod { | |||
| Description: "Removes 'tools.serena' and adds an equivalent 'imports' entry using shared/mcp/serena.md with languages.", | ||||
| IntroducedIn: "1.0.0", | ||||
| Apply: func(content string, frontmatter map[string]any) (string, bool, error) { | ||||
| toolsAny, hasTools := frontmatter["tools"] | ||||
| if !hasTools { | ||||
| return content, false, nil | ||||
| } | ||||
|
|
||||
| toolsMap, ok := toolsAny.(map[string]any) | ||||
| if !ok { | ||||
| return content, false, nil | ||||
| } | ||||
|
|
||||
| serenaAny, hasSerena := toolsMap["serena"] | ||||
| if !hasSerena { | ||||
| return content, false, nil | ||||
| } | ||||
|
|
||||
| languages, ok := extractSerenaLanguages(serenaAny) | ||||
| languages, ok := findSerenaLanguagesForMigration(frontmatter) | ||||
| if !ok || len(languages) == 0 { | ||||
| serenaImportCodemodLog.Print("Found tools.serena but languages configuration is invalid or empty - skipping migration; verify tools.serena languages are set") | ||||
| return content, false, nil | ||||
| } | ||||
|
|
||||
|
|
@@ -50,7 +34,8 @@ func getSerenaToSharedImportCodemod() Codemod { | |||
| return lines, false | ||||
| } | ||||
|
|
||||
| result = removeTopLevelBlockIfEmpty(result, "tools") | ||||
| result = removeBlockIfEmpty(result, "tools") | ||||
| result = removeBlockIfEmpty(result, "engine") | ||||
|
|
||||
| if alreadyImported { | ||||
| return result, true | ||||
|
|
@@ -59,6 +44,7 @@ func getSerenaToSharedImportCodemod() Codemod { | |||
| return addSerenaImport(result, languages), true | ||||
| }) | ||||
| if applied { | ||||
| newContent = maybeUpdatePinnedSourceRef(newContent, frontmatter) | ||||
| if alreadyImported { | ||||
| serenaImportCodemodLog.Print("Removed tools.serena (shared/mcp/serena.md import already present)") | ||||
| } else { | ||||
|
|
@@ -70,6 +56,53 @@ func getSerenaToSharedImportCodemod() Codemod { | |||
| } | ||||
| } | ||||
|
|
||||
| func findSerenaLanguagesForMigration(frontmatter map[string]any) ([]string, bool) { | ||||
| toolsAny, hasTools := frontmatter["tools"] | ||||
| if hasTools { | ||||
| if toolsMap, ok := toolsAny.(map[string]any); ok { | ||||
| if serenaAny, hasSerena := toolsMap["serena"]; hasSerena { | ||||
| languages, ok := extractSerenaLanguages(serenaAny) | ||||
| if ok && len(languages) > 0 { | ||||
| return languages, true | ||||
| } | ||||
| return nil, false | ||||
|
||||
| return nil, false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The codemod metadata strings still describe only migrating top-level
tools.serena, but the implementation now also supportsengine.tools.serenaand may rewrite a pinnedsource:ref to@main. Please update theName/Descriptionto accurately reflect the new behavior so users understand what the codemod can change.See below for a potential fix: