-
Notifications
You must be signed in to change notification settings - Fork 34
Build safe outputs from safe outputs schema with esbuild and add agent-mode control #5987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: pelikhan <[email protected]>
- Add schema_parser.go to parse agent-output.json schema - Update generate_action_metadata_command.go to use schema instead of hardcoded list - Extract safe output types from schema definitions - Generate 11 custom actions from schema (was 5 hardcoded) - Actions now include proper descriptions from schema Co-authored-by: pelikhan <[email protected]>
- Add comprehensive unit tests for schema parsing functions - Fix gosimple linter errors (unnecessary fmt.Sprintf) - Remove unused extractActionMetadata function - All tests pass, linter passes Co-authored-by: pelikhan <[email protected]>
| @@ -0,0 +1,384 @@ | |||
| // @ts-check | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot actions//src/.js should be gitignored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit ea114d4. All generated action directories are now in .gitignore, including their src/*.js files. The files remain on disk for local development but are not committed to the repository.
| @@ -0,0 +1,69 @@ | |||
| # Add Issue Comment Output | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot actions/*/README.md should be gitignored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit ea114d4. All generated README.md files for the 11 schema-driven actions are now gitignored. The actions can still be generated locally with make generate-action-metadata.
- Add t.Cleanup() to restore registry state after tests modify it - Fix TestCustomActionModeCompilation to only check create_issue job section - Prevents test failures caused by other jobs using actions/github-script The tests were failing because: 1. Tests modified global DefaultScriptRegistry without proper cleanup 2. Test checked entire workflow file instead of just the create_issue job 3. Other jobs (activation, detection) legitimately use actions/github-script
- Update scripts.go to use RegisterWithAction for types with custom actions - Add GetActionDirectoryName to convert snake_case to kebab-case - Regenerate all custom action directories with hyphenated names - 11 safe output types now have custom actions: noop, minimize-comment, close-issue, close-pull-request, close-discussion, add-comment, create-issue, add-labels, create-discussion, update-issue, update-pull-request - Custom actions follow GitHub Actions naming convention (hyphens) Co-authored-by: pelikhan <[email protected]>
- Add all 11 generated action directories to .gitignore - Untrack previously committed generated files (README.md, action.yml, src/index.js) - Generated actions are created by 'make generate-action-metadata' - Files remain on disk for local development but are not committed Co-authored-by: pelikhan <[email protected]>
pkg/workflow/scripts.go
Outdated
| // Safe output scripts | ||
|
|
||
| // Helper to register scripts that have custom actions | ||
| registerWithAction := func(name, source string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot move action output schema parser into workflow package (own file) and use the schema to drive definition so that the code generator and the compiler use the same source of truth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 5a25e71. Moved schema parser to pkg/workflow/safe_output_schema.go and added GetCustomActionTypes() as the single source of truth. Both the action generator and compiler now use the same schema-driven list, eliminating the duplication between scripts.go and the CLI generator.
…tion - Move schema_parser.go from pkg/cli to pkg/workflow/safe_output_schema.go - Add GetCustomActionTypes() as single source of truth for custom actions - Update scripts.go to use schema-driven registration via GetCustomActionTypes() - Update generate_action_metadata_command.go to use workflow.* functions - Move and update tests to pkg/workflow/safe_output_schema_test.go - Both code generator and compiler now use the same schema source Co-authored-by: pelikhan <[email protected]>
|
@copilot the files under "actions/" have to be commited to the repo AND marked as autogenerated in the gitattributes. |
- Remove generated action directories from .gitignore - Add patterns to .gitattributes to mark generated actions as linguist-generated - Regenerate all 11 custom actions (noop, minimize-comment, close-issue, close-pull-request, close-discussion, add-comment, create-issue, add-labels, create-discussion, update-issue, update-pull-request) - Generated files now committed to repo but marked as auto-generated for GitHub Co-authored-by: pelikhan <[email protected]>
Done in commit 9b20f08. All 11 generated action directories are now committed to the repository and marked as |
|
Add a "feature" "agent-mode" in the front matter that controls the agent mode for a single agentic workflow. This flag overrides the default inferred mode. Set the value to "dev" for dev.md. |
|
@copilot comment above |
- Add AgentMode field to WorkflowData struct - Add extractAgentMode() function to parse agent-mode from frontmatter - Apply agent-mode in CompileWorkflowData to override default action mode - Update main_workflow_schema.json to include agent-mode field (enum: inline, dev) - Set agent-mode: dev in .github/workflows/dev.md - Allows per-workflow control of JavaScript embedding (inline vs custom actions) Co-authored-by: pelikhan <[email protected]>
|
@copilot update dev.md to create an issue with a poem. Remove safeinputs import. Safe outputs in stage mode |
✅ Dev Hawk Report - SuccessWorkflow Run: #3090
The Dev workflow completed successfully! 🎉 Commit Details:
All builds, tests, and validations passed on this branch. The PR is ready for review.
|
- Change workflow to create a poem about GitHub instead of PR summary - Remove imports section (was importing shared/gh.md) - Remove manual steps section - Keep safe-outputs in staged mode - Simplify prompt to write poem and create issue - Recompiled dev.lock.yml with updated workflow Co-authored-by: pelikhan <[email protected]>
Done in commit 6ff1d44. Updated dev.md to:
|
|
|
@copilot the error is a bundling issue. Make sure esbuild resolves all local require into index.js Error: Cannot find module '/home/runner/work/gh-aw/gh-aw/pkg/workflow/js/sanitize_label_content.cjs' |
- Change transformSourceForEsbuild to use static relative paths instead of path.join(__dirname) - Use ../../../pkg/workflow/js/ paths that esbuild can resolve at build time - Remove dynamic path construction with path.join that breaks bundling - Regenerated all action src/index.js with static paths - Rebuilt all 13 actions successfully with dependencies properly inlined - Fixes "Cannot find module" error at runtime Co-authored-by: pelikhan <[email protected]>
Fixed in commit 9d0823b. Changed the code generation to use static relative paths ( |
|
|
@copilot the error message is ReferenceError: core is not defined Make sure esbuild bundles the @actions/core package as well. |
- Add global.core assignment in generated src/index.js - The .cjs files expect 'core' as a global variable (github-script context) - esbuild now properly bundles @actions/core and makes it available globally - Regenerated all 13 actions with global core assignment - Rebuilt all actions successfully with working @actions/core - Fixes "ReferenceError: core is not defined" error Co-authored-by: pelikhan <[email protected]>
Done in commit ef210a4. Added |
|
@copilot the build script needs to scan for usage of githubscriot globals and import them as needed. core, github, context Error: ReferenceError: context is not defined |
|
- Scan generated source for usage of core, github, and context globals - Automatically import @actions/core when core. is detected - Automatically import @actions/github when github. or context. is detected - Make all detected globals available via global.* assignments - Regenerated all 13 actions with proper global detection - Rebuilt all actions with complete @actions dependencies - Fixes "ReferenceError: context is not defined" and similar errors Co-authored-by: pelikhan <[email protected]>
Done in commit d66a2ef. The build script now automatically scans generated source for usage of github-script globals (
All 13 actions have been regenerated and rebuilt with proper automatic dependency detection. |
✅ Dev Hawk Report - SuccessWorkflow Run: #3094
Commit SummaryAuto-detect and import github-script globals (core, github, context) - fixes "ReferenceError: context is not defined" and similar errors by automatically scanning generated source for usage and importing required The Dev workflow completed successfully! 🎉 All checks passed for the safe outputs schema build implementation.
|
Task: Build Safe Outputs from Safe Outputs Schema
Goal: Use the schema of safe output types (
schemas/agent-output.json) to drive the code generation of custom actions folder.Implementation Complete ✅
Schema-driven generation now works with industry-standard tooling and automatic github-script global detection:
schemas/agent-output.jsonKey Components
npm run build: Dev mode - readable, non-minified output for debuggingnpm run build:release: Release mode - minified output for productionAuto-Detection of github-script Globals
The build system now automatically scans generated source files for usage of github-script globals and imports them as needed:
core.→ imports@actions/coreand makesglobal.coreavailablegithub.→ imports@actions/githuband makesglobal.githubavailablecontext.→ imports@actions/github, extractsgithub.context, and makesglobal.contextavailableThis ensures all actions have exactly the dependencies they need without manual configuration.
esbuild Fixes
src/index.jsfiles use static relative paths (../../../pkg/workflow/js/file.cjs) that esbuild can resolve at build timecore.,github., andcontext.usage and imports/exports them automaticallyglobal.*assignments so bundled .cjs files can access themGenerated Actions (11 from schema)
All actions are generated from the schema and bundled with esbuild:
actions/noop/actions/minimize-comment/actions/close-issue/actions/close-pull-request/actions/close-discussion/actions/add-comment/actions/create-issue/actions/add-labels/actions/create-discussion/actions/update-issue/actions/update-pull-request/Plus 2 existing actions (also rebundled with esbuild):
actions/setup-safe-inputs/actions/setup-safe-outputs/Each directory contains:
action.yml- Action metadata (schema-driven)README.md- Documentation (schema-driven)index.js- Bundled by esbuild with all dependencies inlined (committed)Generated but not committed:
src/index.js- Generated source file (gitignored, regenerated by make generate-action-metadata)src/*.cjs- Intermediate build artifacts (gitignored)All committed generated files are marked as
linguist-generated=truein.gitattributes.Building Actions
Generated actions can be rebuilt using:
The build process:
make generate-action-metadatagenerates action.yml, README.md, and src/index.js from schema with automatic detection of github-script globalsmake actions-buildormake actions-build-releaseruns npm ci and esbuild<issue_title>build safe outputs from safe outputs schema</issue_title>
><issue_description>Use the schema of safe output types to drive the code generation of custom actions folder.
></issue_description>
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.