feat(cli): JSON workflow importer - trigger/tool/permissions mapping#33376
Conversation
…apping - Extends ConvertJSONWorkflowToMarkdown to handle prompt, triggers, tools, and permissions fields from Copilot automation JSON payloads - Maps interval triggers to gh-aw fuzzy schedule expressions (every 1h / daily / weekly) instead of raw cron - Maps issues and workflow_run triggers to on: frontmatter blocks - Maps GitHub tool IDs to tools: github: toolsets: [...] via a 40-entry lookup table; execute -> bash: "*"; web_search -> web-search: - Passthrough permissions map to permissions: frontmatter - Falls back to prompt field for workflow body when instructions absent - Adds two real-world anonymized test cases from the automation API Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Completes the add --wizard JSON workflow importer by translating previously “unknown” JSON fields (prompt, triggers, tools, permissions) into first-class gh-aw frontmatter/body output, with warnings where gh-aw lacks an equivalent.
Changes:
- Adds structured trigger conversion (
triggers→on:) including interval shorthand and multi-trigger map emission. - Adds tool ID mapping (
tools→tools:) with a lookup table + special cases (execute→bash: "*",web_search→web-search:). - Adds prompt-as-body fallback and permissions passthrough (
permissions→permissions:), plus new tests for real-world payloads.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/jsonworkflow_to_markdown.go | Implements triggers/tools/permissions/prompt mapping into markdown frontmatter/body, including conversion helpers and warnings. |
| pkg/cli/jsonworkflow_to_markdown_test.go | Adds importer test cases covering interval triggers, multi-trigger conversion, tool mapping, permissions, and warnings. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
| wfEntry := map[string]any{ | ||
| "workflows": t.WorkflowRun.Workflows, | ||
| "types": t.WorkflowRun.Types, | ||
| } | ||
| if len(t.WorkflowRun.Conclusions) > 0 { | ||
| warnings = append(warnings, `triggers.workflow_run.conclusions has no gh-aw equivalent; review the generated "on:" block`) | ||
| } | ||
| parts["workflow_run"] = wfEntry |
|
@copilot review all comments, lint go |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot fix lint, format code https://github.com/github/gh-aw/actions/runs/26116030916/job/76806717111?pr=33376 |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed in b79223e. I checked the linked CI job, reproduced the failing |
|
✅ smoke-ci: safeoutputs CLI comment + comment-memory run (26117227063)
|
…l default - setup/cli.md: add JSON workflow importer field mapping table (triggers, tools, permissions, prompt) for `gh aw add` and `gh aw add-wizard` (PR #33376). - reference/model-tables.md: add `gemini-3.5-flash` (multiplier 14) to the Google table (PR #33430). - reference/safe-outputs.md: describe the default collapsed `<details>` disclosure produced by the `footer-install` template (PR #33368). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Why
The
add --wizardcommand can import workflows from JSON payloads (Copilot automation API). Previously, theprompt,triggers,tools, andpermissionsfields all fell through to unrecognized-field comments rather than being translated into first-class gh-aw frontmatter. This PR completes that mapping.What changed
Trigger mapping (
triggers->on:)interval: hourly/daily/weekly-> gh-aw fuzzy schedule expressions (every 1h,daily,weekly) -- NOT raw cron; the compiler randomises cron at compile timeon: daily); multiple triggers use the map formissues->on: issues: types: [...]; warns whenqueryfilter is present (no gh-aw equivalent)workflow_run->on: workflow_run: workflows: [...] types: [...]; warns onconclusionsfilterTool mapping (
tools->tools:)issues,pull-requests,repos, etc.)execute->bash: "*"(with a review warning)web_search->web-search:(direct mapping, underscore->hyphen normalised)Other fields
promptis used as the workflow body wheninstructionsis absentpermissionsmap is passed through to thepermissions:frontmatter blockTest coverage
Two anonymized real-world API payloads are used as test cases:
IntervalTrigger- single interval trigger, prompt-as-bodyMultiTriggerWithTools- issues + workflow_run triggers, tool migration, permissions, Extra warnings