-
Notifications
You must be signed in to change notification settings - Fork 28
Add close-issue safe output for automated issue cleanup #4554
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
… workflow Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
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.
Pull request overview
This PR adds a new close-issue safe output type to enable automated cleanup of duplicate issues. The implementation follows the established close-discussion pattern and includes Go backend code, JavaScript execution script, JSON schema validation, and a practical example in the semantic-function-refactor workflow.
Key changes:
- Implements
close-issuesafe output with filtering by title prefix, labels, and target - Adds security features (required title prefix prevents closing wrong issues)
- Supports batch operations (configurable max 1-100 issues)
- Includes cross-repo support via
target-repofield
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/close_issue.go |
Core Go implementation with config parser and job builder |
pkg/workflow/js/close_issue.cjs |
JavaScript script for GitHub API operations (has critical bug) |
pkg/workflow/safe_outputs.go |
Integration points for safe output system |
pkg/workflow/compiler.go |
Type definition for CloseIssuesConfig struct |
pkg/workflow/compiler_jobs.go |
Job builder integration |
pkg/workflow/scripts.go |
Script embedding and bundling setup |
pkg/parser/schemas/main_workflow_schema.json |
JSON schema validation rules |
pkg/workflow/js/safe_outputs_tools.json |
MCP tool definition for AI agents |
pkg/workflow/safe_outputs_tools_test.go |
Test expectations update |
.github/workflows/semantic-function-refactor.md |
Example workflow using close-issue |
.github/workflows/semantic-function-refactor.lock.yml |
Compiled workflow output |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot lint and fix JavaScript tests |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Add documentation for three new safe output types merged in the last 24 hours: - close-issue: Close GitHub issues with comment and state reason filtering - add-reviewer: Add reviewers to pull requests with allowlist support - close-pull-request: Close PRs without merging with label/title filtering Changes made: - Added entries to safe outputs table in reference documentation - Added detailed configuration sections for each new safe output type - Included examples with all configuration options - Documented target modes, filtering options, and cross-repo support Features documented from: - PR #4568: close-pull-request safe output - PR #4564: add-reviewer safe output - PR #4554: close-issue safe output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implementation Complete:
close-issueSafe Output TypeChanges Made
CloseIssuesConfigstruct inpkg/workflow/compiler.goclose_issue.gowith parsing and job building logic (followingclose_discussion.gopattern)close_issue.cjsJavaScript implementation (followingclose_discussion.cjspattern)close_issue.test.cjscomprehensive test suite ✅ NEWsafe_outputs.goto includeCloseIssuesin:HasSafeOutputsEnabled()function ✓pkg/parser/schemas/main_workflow_schema.jsonpkg/workflow/scripts.gopkg/workflow/scripts.go(getCloseIssueScript())semantic-function-refactor.mdto useclose-issueinstead ofupdate-issueclose_issuetool tosafe_outputs_tools.jsoncompiler_jobs.goto build close_issue jobsafe_outputs_tools_test.goTest Coverage for close_issue.cjs
✅ 10 comprehensive test cases:
Test Results
Original prompt
This section details on the original issue you should resolve
<issue_title>[q] Close existing [refactor] issues before creating new one</issue_title>
<issue_description># Q Workflow Optimization Report
Context
This fix addresses issue #4543, where the
semantic-function-refactorworkflow was creating duplicate issues with the[refactor]title prefix. Currently, there are 7 open issues with this prefix, all created by this workflow.Issue Evidence:
Changes Made
Modified Workflow:
semantic-function-refactor.md1. Added Safe Output Capabilities
2. Enhanced GitHub Tools
3. Updated Mission Instructions
Added explicit instructions to close existing
[refactor]issues BEFORE performing analysis:4. Added New Task Step
Inserted a new critical first step:
5. Updated Permissions
Note: Removed
issues: writepermission as the workflow usesstrict: truemode. Write operations are handled safely through the safe-outputs system.Expected Improvements
Immediate Impact
[refactor]issues before creating a new oneBehavior Change
Before:
[refactor]issue each runAfter:
[refactor]issues[refactor]issueValidation
✅ Workflow compiled successfully:
Schema Validation
Testing Recommendations
workflow_dispatchtriggerImplementation Notes
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.