Add source field to track workflow origin in frontmatter#1234
Conversation
Implements source field in workflow frontmatter that tracks where workflows were added from. - Add Source field to WorkflowData struct - Add extractSource method to extract source from frontmatter - Render source field as comment in lock files (after description, before stop-time) - Add source field to schema validation (main_workflow_schema.json) - Update add_command to inject source field when installing workflows - Add buildSourceString helper to format source string (owner/repo@ref/path) - Add addSourceToWorkflow helper to update workflow frontmatter - Add comprehensive tests for source field parsing and rendering Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
The source field format is now owner/repo/path@ref (version at end) instead of owner/repo@ref/path (version in middle). This matches the add command syntax where version comes after the path: - gh aw add githubnext/agentics/ci-doctor@v1.0.0 Updated: - buildSourceString to put version at end - All tests to use correct format - Schema description to reflect correct format Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed the source field format to match add command syntax. The format is now Example:
All tests updated and passing. Round-trip consistency verified (parse → buildSourceString produces correct format). Commit: 45c4f78 |
There was a problem hiding this comment.
Pull Request Overview
Adds a new source field to workflow frontmatter that tracks where workflows were added from using the gh aw add command. This field follows the format owner/repo/path@ref and is rendered as a comment in generated lock files.
Key Changes:
- Added
Sourcefield toWorkflowDatastruct for parsing and storing source information - Extended add command to inject source field when installing workflows
- Added schema validation and comprehensive test coverage for the new functionality
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/compiler.go | Added Source field to WorkflowData struct and extractSource method for parsing frontmatter |
| pkg/parser/schemas/main_workflow_schema.json | Added source field definition to JSON schema validation |
| pkg/cli/add_command.go | Added buildSourceString and addSourceToWorkflow helpers to inject source field during workflow installation |
| pkg/workflow/source_field_test.go | Comprehensive test suite for source field extraction and rendering functionality |
| pkg/cli/add_source_test.go | Test suite for add command source field helpers |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@copilot merge main, Run add command to githubnext/agentics ci-doctor and check source is present |
|
@copilot update frontmatter docs |
- Merged latest main branch changes - Verified source field format: owner/repo/path@ref - All unit tests pass - Source field correctly rendered in lock files The source field is automatically added by the add command and matches the command syntax exactly. Example: Command: gh aw add githubnext/agentics/ci-doctor@v1.0.0 Source: githubnext/agentics/workflows/ci-doctor.md@v1.0.0 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Merged main branch successfully. The source field is working correctly: Demonstration:
All unit tests pass. The format matches the add command syntax exactly (version at the end). Note: Cannot run the actual add command with GitHub credentials in this environment, but the source field injection logic is tested and verified through:
Commit: 6e25985 |
|
Manual check needed... update investigate why add fails in copilot mode. |
Added comprehensive documentation for: - description field: Human-readable description rendered in lock files - source field: Tracks workflow origin from gh aw add command Documentation updated in: - docs/src/content/docs/reference/frontmatter.md (detailed sections) - .github/instructions/github-agentic-workflows.instructions.md (field list) Both fields are optional and enhance workflow traceability and documentation. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated frontmatter documentation with detailed sections for both Documentation locations:
The documentation includes:
Commit: 56b7cf1 |
|
@copilot provide a detailed error report/investigation why the "add" command fails. |
Add Command Failure InvestigationRoot Cause: GitHub CLI authentication is missing in the sandboxed environment. Error: Call Stack: Why: Source Field Status:
Code Flow (lines 448-458 in add_command.go): sourceString := buildSourceString(workflow) // Creates: owner/repo/path@ref
updatedContent, err := addSourceToWorkflow(content, sourceString, verbose)
content = updatedContent // Injects source into frontmatterWorkarounds:
The source field feature is complete. The add command failure is an authentication limitation, not a code issue. |
| result.Frontmatter["source"] = source | ||
|
|
||
| // Convert back to YAML | ||
| updatedFrontmatter, err := yaml.Marshal(result.Frontmatter) |
There was a problem hiding this comment.
@copilot use helper that fixes yaml marshaling issues with "on"
There was a problem hiding this comment.
Applied UnquoteYAMLKey helper to fix YAML marshaling issues with 'on' keyword.
Changes:
- Exported
unquoteYAMLKeyasUnquoteYAMLKey - Applied in
addSourceToWorkflowto prevent "on" from being quoted - Added test case to verify "on" remains unquoted
- Updated all references across codebase
The "on" keyword is now properly unquoted when adding source field to workflows.
Commit: 3ee8a9c
- Export unquoteYAMLKey as UnquoteYAMLKey for use in other packages - Update all references to use the exported version - Apply UnquoteYAMLKey in addSourceToWorkflow to prevent "on" from being quoted - Add test case to verify "on" keyword is not quoted after adding source field This ensures that when source field is added to workflows with 'on' triggers, the 'on' keyword remains unquoted in the frontmatter YAML. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
#1234) - Add field-level merge support for create-discussion in imports.go - Create shared/daily-audit-discussion.md with base config - Update 42 workflows to import the shared component - Add 3 tests for create-discussion field-level merging - Recompile all 173 workflow lock files Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
) - Add actions/setup/md/agentic_workflows_guide.md with MCP usage guidance - Add agenticWorkflowsGuideFile constant in prompt_constants.go - Add hasAgenticWorkflowsTool helper in prompts.go - Inject guide in collectPromptSections when agentic-workflows tool is configured - Update smoke-copilot golden file - Add tests for inclusion/exclusion of the guide - Recompile all 173 lock files Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Add support for the "source" field in workflow frontmatter ✓
Summary
Successfully implemented the
sourcefield in workflow frontmatter that tracks where workflows were added from using thegh aw addcommand. Merged with main branch, all tests passing, and comprehensive documentation added.Implementation Completed ✓
Sourcefield toWorkflowDatastructextractSourcemethod to extract source from frontmattermain_workflow_schema.json)add_command.goto inject source field when installing workflowsbuildSourceStringhelper to format source stringaddSourceToWorkflowhelper to update workflow frontmatterFormat
Source field format:
owner/repo/path@ref(version at the END)This matches the add command syntax where the version comes after the path:
gh aw add githubnext/agentics/ci-doctor@v1.0.0 # Produces source: githubnext/agentics/workflows/ci-doctor.md@v1.0.0Examples:
githubnext/agentics/workflows/ci-doctor.md@v1.0.0(with version tag)githubnext/agentics/workflows/daily-plan.md@main(with branch)githubnext/agentics/workflows/helper-bot.md(no version)Documentation
Complete documentation added to:
docs/src/content/docs/reference/frontmatter.md: Detailed sections for bothdescriptionandsourcefields with examples, formatting, and benefits.github/instructions/github-agentic-workflows.instructions.md: Added to Agentic Workflow Specific Fields listThe documentation includes:
gh aw addDemonstration
Workflow File (ci-doctor.md)
Generated Lock File (ci-doctor.lock.yml)
Testing
Files Changed
pkg/workflow/compiler.go- Added Source field and extraction logicpkg/cli/add_command.go- Added source field injection with correct format and YAML helperpkg/parser/schemas/main_workflow_schema.json- Added source field to schemapkg/workflow/source_field_test.go- Comprehensive tests for source fieldpkg/cli/add_source_test.go- Tests for add command helpersdocs/src/content/docs/reference/frontmatter.md- Documentation for source and description fields.github/instructions/github-agentic-workflows.instructions.md- Updated field listpkg/workflow/yaml.go- Exported UnquoteYAMLKey helperpkg/workflow/tools.go- Updated to use UnquoteYAMLKeypkg/workflow/yaml_test.go- Updated test referencesOriginal prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.