Skip to content

feat(cli): JSON workflow importer - trigger/tool/permissions mapping#33376

Merged
pelikhan merged 6 commits into
mainfrom
pelikhan/get-automation-api
May 19, 2026
Merged

feat(cli): JSON workflow importer - trigger/tool/permissions mapping#33376
pelikhan merged 6 commits into
mainfrom
pelikhan/get-automation-api

Conversation

@pelikhan
Copy link
Copy Markdown
Collaborator

Why

The add --wizard command can import workflows from JSON payloads (Copilot automation API). Previously, the prompt, triggers, tools, and permissions fields 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 time
  • Single interval trigger emits the inline shorthand (on: daily); multiple triggers use the map form
  • issues -> on: issues: types: [...]; warns when query filter is present (no gh-aw equivalent)
  • workflow_run -> on: workflow_run: workflows: [...] types: [...]; warns on conclusions filter

Tool mapping (tools -> tools:)

  • 40-entry lookup table maps GitHub tool IDs to gh-aw toolsets (issues, pull-requests, repos, etc.)
  • execute -> bash: "*" (with a review warning)
  • web_search -> web-search: (direct mapping, underscore->hyphen normalised)
  • Built-in read/edit/search tools are silently skipped (no config needed)
  • Unknown tools emit a per-tool warning

Other fields

  • prompt is used as the workflow body when instructions is absent
  • permissions map is passed through to the permissions: frontmatter block

Test coverage

Two anonymized real-world API payloads are used as test cases:

  • IntervalTrigger - single interval trigger, prompt-as-body
  • MultiTriggerWithTools - issues + workflow_run triggers, tool migration, permissions, Extra warnings

…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>
Copilot AI review requested due to automatic review settings May 19, 2026 17:49
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 (triggerson:) including interval shorthand and multi-trigger map emission.
  • Adds tool ID mapping (toolstools:) with a lookup table + special cases (executebash: "*", web_searchweb-search:).
  • Adds prompt-as-body fallback and permissions passthrough (permissionspermissions:), 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

Comment thread pkg/cli/jsonworkflow_to_markdown.go Outdated
Comment on lines +435 to +442
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
@pelikhan
Copy link
Copy Markdown
Collaborator Author

@copilot review all comments, lint go

Copilot AI and others added 2 commits May 19, 2026 18:05
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

@copilot review all comments, lint go

Addressed in 330a650. I reviewed the prior actionable feedback, now skip incomplete workflow_run imports unless both workflows and types are present, added a regression test, and make golint / go test ./pkg/cli both pass.

@pelikhan
Copy link
Copy Markdown
Collaborator Author

Copilot AI and others added 2 commits May 19, 2026 18:21
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

@copilot fix lint, format code https://github.com/github/gh-aw/actions/runs/26116030916/job/76806717111?pr=33376

Addressed in b79223e. I checked the linked CI job, reproduced the failing lint-cjs Prettier check locally, formatted actions/setup/js/create_pull_request.cjs, and re-ran the formatting gate plus make golint successfully.

@pelikhan pelikhan merged commit cbe9b26 into main May 19, 2026
13 of 14 checks passed
@pelikhan pelikhan deleted the pelikhan/get-automation-api branch May 19, 2026 18:31
@github-actions
Copy link
Copy Markdown
Contributor

✅ smoke-ci: safeoutputs CLI comment + comment-memory run (26117227063)

Generated by 🧪 Smoke CI for issue #33376 ·

github-actions Bot added a commit that referenced this pull request May 20, 2026
…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>
Sign up for free to 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