Add support for importing safe-outputs from shared agentic workflows#4761
Add support for importing safe-outputs from shared agentic workflows#4761
Conversation
…flows Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
|
||
| // safeOutputTypeKeys lists all the safe output type keys that are used in frontmatter | ||
| // These are the keys that define actual safe output operations (not meta configuration like app, jobs, staged, etc.) | ||
| var safeOutputTypeKeys = []string{ |
There was a problem hiding this comment.
@copilot can you mine these keys from of an the embedded main JSON schema?
There was a problem hiding this comment.
Added GetSafeOutputTypeKeys() in pkg/parser/schema.go that parses the embedded main_workflow_schema.json and extracts safe-output type keys dynamically. Meta-configuration fields (allowed-domains, staged, env, github-token, app, max-patch-size, jobs, runs-on) are filtered out. Results are cached using sync.Once for performance. Commit: 1c94c28
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot also allow import safe output meta fields |
There was a problem hiding this comment.
Pull request overview
This PR adds support for importing safe-output configurations (such as create-issue, add-comment, create-discussion) from shared agentic workflows using the imports: field. The implementation extracts safe output type keys dynamically from the embedded JSON schema rather than hardcoding them, and includes conflict detection to prevent the same safe-output type from being defined in multiple locations.
Key changes:
- Dynamic schema-based safe output type extraction for maintainability
- Conflict detection between main and imported safe-output configurations
- Comprehensive test coverage for import scenarios and edge cases
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/schema.go | Adds GetSafeOutputTypeKeys() function to extract safe output type keys from the embedded main workflow schema, filtering out meta-configuration fields like allowed-domains, staged, and env |
| pkg/parser/schema_test.go | Adds comprehensive test for GetSafeOutputTypeKeys() verifying correct extraction of safe output types and exclusion of meta fields |
| pkg/workflow/imports.go | Implements MergeSafeOutputs() with conflict detection, uses schema-extracted keys with caching, includes hasSafeOutputType() and mergeSafeOutputConfig() helper functions |
| pkg/workflow/compiler.go | Integrates safe-outputs merging into the workflow parsing pipeline after processing other imports |
| pkg/workflow/safe_outputs_import_test.go | Provides comprehensive integration and unit tests covering import scenarios, conflict detection (main vs import, import vs import), and multi-workflow imports |
| docs/src/content/docs/labs.mdx | Adds entry for "Daily Fact About gh-aw" workflow (appears unrelated to the PR's core purpose) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
@copilot the safe-outputs content in app-config.md should also be importable (the |
…orkflows Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
The |
|
✅ Agentic Changeset Generator completed successfully. |
Updates documentation for three major features merged in the last 24 hours: 1. CLI --ref flag (#4776) - Add --ref flag to gh aw status command - Add --ref flag to gh aw logs command - Shows latest run status when filtering by branch/tag 2. Import safe-outputs from shared workflows (#4761, #4782) - Document safe-outputs importing capability - Document safe output jobs import support - Explain conflict detection and meta field precedence 3. Custom job outputs support (#4778) - Document job output definition syntax - Show usage in agent prompts with needs context - Note string value requirement 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
This PR adds support for importing safe-outputs (like
create-issue,add-comment,create-discussion, etc.) and meta fields from shared agentic workflows using theimports:field.Changes
pkg/parser/schema.go: AddedGetSafeOutputTypeKeys()function to extract safe output type keys from the embedded main workflow schema, filtering out meta-configuration fieldspkg/workflow/imports.go:parser.GetSafeOutputTypeKeys()instead of a hardcoded list, with caching for performanceallowed-domains,staged,env,github-token,max-patch-size,runs-onpkg/workflow/compiler.go: Integrated merge into workflow parsing pipelinepkg/workflow/safe_outputs_import_test.go: Comprehensive tests for import and conflict scenarios, including meta field testspkg/parser/schema_test.go: Added test forGetSafeOutputTypeKeys()Usage
Shared workflow (
shared-config.md):Main workflow:
Conflict handling
If the same safe-output type is defined in both main and imported workflow:
Note: Main workflow values take precedence over imported values for meta fields.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.