(filePath string, appliedCodemods []string, content string, verbose bool)
| 367 | ` |
| 368 | |
| 369 | func scaffoldSerenaSharedWorkflowIfNeeded(filePath string, appliedCodemods []string, content string, verbose bool) error { |
| 370 | if !wasAnyCodemodApplied( |
| 371 | appliedCodemods, |
| 372 | "Migrate tools.serena to shared Serena import", |
| 373 | "Migrate tools.serena or engine.tools.serena to shared Serena import", |
| 374 | ) { |
| 375 | return nil |
| 376 | } |
| 377 | if !strings.Contains(content, "shared/mcp/serena.md") { |
| 378 | return nil |
| 379 | } |
| 380 | |
| 381 | workflowRoot := resolveWorkflowRoot(filePath) |
| 382 | serenaPath := filepath.Join(workflowRoot, "shared", "mcp", "serena.md") |
| 383 | if _, err := os.Stat(serenaPath); err == nil { |
| 384 | return nil |
| 385 | } else if !os.IsNotExist(err) { |
| 386 | return err |
| 387 | } |
| 388 | |
| 389 | if err := os.MkdirAll(filepath.Dir(serenaPath), constants.DirPermPublic); err != nil { |
| 390 | return err |
| 391 | } |
| 392 | |
| 393 | if err := os.WriteFile(serenaPath, []byte(scaffoldedSerenaSharedWorkflow), constants.FilePermSensitive); err != nil { |
| 394 | return err |
| 395 | } |
| 396 | |
| 397 | if verbose { |
| 398 | fmt.Fprintf(os.Stderr, "%s\n", console.FormatInfoMessage("Scaffolded "+serenaPath)) |
| 399 | } |
| 400 | |
| 401 | return nil |
| 402 | } |
| 403 | |
| 404 | func wasCodemodApplied(appliedCodemods []string, codemodName string) bool { |
| 405 | return slices.Contains(appliedCodemods, codemodName) |
no test coverage detected