convertToolsToConfig maps a list of JSON tool IDs to a gh-aw tools config map (the value under the "tools:" frontmatter key) and any conversion warnings. Tool ID format: bare ("issue_read") or prefixed ("github/issue_read"). Mapping: github/* → tools: github: toolsets: [ ] execu
(tools []string)
| 539 | // web_search → tools: web-search: (direct mapping, hyphen-normalised) |
| 540 | // read/edit/search → (built-in capability, no config needed, no warning) |
| 541 | func convertToolsToConfig(tools []string) (map[string]any, []string) { |
| 542 | if len(tools) == 0 { |
| 543 | return nil, nil |
| 544 | } |
| 545 | |
| 546 | var warnings []string |
| 547 | toolsets := map[string]struct { |
| 548 | }{} |
| 549 | config := map[string]any{} |
| 550 | needsBash := false |
| 551 | |
| 552 | for _, id := range tools { |
| 553 | bare := strings.TrimPrefix(id, "github/") |
| 554 | if jsonGeneralTools[bare] { |
| 555 | continue |
| 556 | } |
| 557 | switch bare { |
| 558 | case "execute": |
| 559 | needsBash = true |
| 560 | case "web_search": |
| 561 | // JSON uses underscore; gh-aw frontmatter uses hyphen. |
| 562 | config["web-search"] = nil |
| 563 | default: |
| 564 | if ts := jsonToolToToolset[bare]; ts != "" { |
| 565 | toolsets[ts] = struct { |
| 566 | }{} |
| 567 | } else { |
| 568 | warnings = append(warnings, fmt.Sprintf("tool %q has no known gh-aw mapping and was skipped", id)) |
| 569 | } |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | if len(toolsets) > 0 { |
| 574 | sorted := sliceutil.SortedKeys(toolsets) |
| 575 | config["github"] = map[string]any{"toolsets": sorted} |
| 576 | } |
| 577 | if needsBash { |
| 578 | config["bash"] = "*" |
| 579 | warnings = append(warnings, `tool "execute" was mapped to bash: "*"; review the bash permissions`) |
| 580 | } |
| 581 | jsonWorkflowLog.Printf("Converted %d tool(s): %d toolset(s), bash=%t, %d warning(s)", |
| 582 | len(tools), len(toolsets), needsBash, len(warnings)) |
| 583 | return config, warnings |
| 584 | } |
no test coverage detected