Skip to content

Commit 9172c61

Browse files
committed
Output GH issues to /dist/issues folder
1 parent 1bc378c commit 9172c61

9 files changed

Lines changed: 305 additions & 42 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
### Changed
2626
- **README.md**: Added GitHub Issue Creator to tools table and usage documentation
2727
- **Template Support**: Templates now support optional `GITHUB_REPO` field for automated issue creation
28+
- **GitHub Issue Footer**: Changed from broken relative links to local file paths in code blocks for better usability
29+
- **GitHub Issue Creator**: Made `GITHUB_REPO` truly optional - script will generate issue body without creating the issue if no repo is specified
30+
- **Issue Persistence**: When no GitHub repo is specified, issue bodies are now saved to `dist/issues/GH-issue-{SCAN_ID}.md` for manual copy/paste to GitHub or project management apps
31+
- **AI Instructions**: Updated `dist/TEMPLATES/_AI_INSTRUCTIONS.md` with complete Phase 3 (GitHub Issue Creation) workflow documentation
2832

2933
## [1.3.1] - 2026-01-12
3034

PROJECT/3-COMPLETED/GITHUB-ISSUE-CREATION-FEATURE.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ Implemented automated GitHub issue creation from scan results with AI triage dat
4040

4141
## Features
4242

43-
**Auto-formatted Issues** - Clean, actionable GitHub issues with checkboxes
44-
**AI Triage Integration** - Shows confirmed issues vs. needs review
45-
**Template Integration** - Reads GitHub repo from project templates
46-
**Interactive Preview** - Review before creating the issue
47-
**Confidence Levels** - Shows AI confidence for each finding
48-
**File Path Cleanup** - Removes local paths for cleaner display
49-
**Timezone Conversion** - Converts UTC timestamps to local time
50-
**Report Links** - Includes links to full HTML and JSON reports
43+
**Auto-formatted Issues** - Clean, actionable GitHub issues with checkboxes
44+
**AI Triage Integration** - Shows confirmed issues vs. needs review
45+
**Template Integration** - Reads GitHub repo from project templates (optional)
46+
**Interactive Preview** - Review before creating the issue
47+
**Confidence Levels** - Shows AI confidence for each finding
48+
**File Path Cleanup** - Removes local paths for cleaner display
49+
**Timezone Conversion** - Converts UTC timestamps to local time
50+
**Local File Paths** - Shows local report paths instead of broken links
51+
**Graceful Degradation** - Works without GitHub repo, saves to `dist/issues/` for manual use
5152

5253
## Usage
5354

@@ -79,12 +80,17 @@ The script generates issues with:
7980

8081
## Testing
8182

82-
✅ Tested with Elementor v3.34.1 scan (200 AI-triaged findings)
83-
✅ Created test issue #67 in Hypercart-Dev-Tools/WP-Code-Check
84-
✅ Verified issue format and content
85-
✅ Verified file path cleanup
86-
✅ Verified timezone conversion
83+
✅ Tested with Elementor v3.34.1 scan (200 AI-triaged findings)
84+
✅ Tested with Hypercart Helper v1.1.4 scan (4 AI-triaged findings)
85+
✅ Created test issue #67 in Hypercart-Dev-Tools/WP-Code-Check
86+
✅ Created production issue #7 in NeochromeTeam/hypercart-helper
87+
✅ Verified issue format and content
88+
✅ Verified file path cleanup
89+
✅ Verified timezone conversion
8790
✅ Verified interactive preview
91+
✅ Verified local file paths in footer (no broken links)
92+
✅ Verified graceful degradation without GitHub repo
93+
✅ Verified persistent issue files saved to `dist/issues/`
8894

8995
## Integration
9096

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,23 +171,30 @@ See [TEMPLATES/_AI_INSTRUCTIONS.md](dist/TEMPLATES/_AI_INSTRUCTIONS.md) for deta
171171
Automatically create GitHub issues from scan results with AI triage data:
172172

173173
```bash
174-
# Create issue from latest scan
174+
# Create issue from latest scan (specify repo)
175175
./dist/bin/create-github-issue.sh \
176176
--scan-id 2026-01-12-155649-UTC \
177177
--repo owner/repo
178178

179-
# Or use template's GitHub repo
179+
# Or use template's GitHub repo (if GITHUB_REPO is set in template)
180180
./dist/bin/create-github-issue.sh --scan-id 2026-01-12-155649-UTC
181+
182+
# Generate issue body without creating (no repo needed)
183+
# Useful for manual issue creation or when repo is not specified
184+
./dist/bin/create-github-issue.sh --scan-id 2026-01-12-155649-UTC
185+
# → Saves to dist/issues/GH-issue-2026-01-12-155649-UTC.md
181186
```
182187

183188
**Features:**
184189
-**Auto-formatted Issues** - Clean, actionable GitHub issues with checkboxes
185190
-**AI Triage Integration** - Shows confirmed issues vs. needs review
186-
-**Template Integration** - Reads GitHub repo from project templates
191+
-**Template Integration** - Reads GitHub repo from project templates (optional)
187192
-**Interactive Preview** - Review before creating the issue
193+
-**Graceful Degradation** - Works without GitHub repo (generates issue body only)
194+
-**Persistent Issue Files** - Saves to `dist/issues/` with matching filename pattern for easy manual copy/paste
188195

189196
**Requirements:**
190-
- GitHub CLI (`gh`) installed and authenticated
197+
- GitHub CLI (`gh`) installed and authenticated (only for creating issues)
191198
- Scan with AI triage data (`--ai-triage` flag)
192199

193200
---
@@ -218,6 +225,24 @@ WP Code Check is a **complete code quality suite** with multiple specialized too
218225
- **Deep Review**: Quick Scanner + Golden Rules (experimental)
219226
- **Legacy Audit**: Quick Scanner + Baseline + Golden Rules (experimental)
220227

228+
### Output Directories
229+
230+
All scan outputs are organized in the `dist/` directory:
231+
232+
| Directory | Contents | Git Tracked | Purpose |
233+
|-----------|----------|-------------|---------|
234+
| `dist/logs/` | JSON scan results (`*.json`) | ❌ No | Machine-readable scan data |
235+
| `dist/reports/` | HTML reports (`*.html`) | ❌ No | Human-readable scan reports |
236+
| `dist/issues/` | GitHub issue bodies (`GH-issue-*.md`) | ❌ No | Manual copy/paste to GitHub or project management apps |
237+
| `dist/TEMPLATES/` | Project templates (`*.txt`) | ✅ Yes | Reusable scan configurations |
238+
239+
**Filename Pattern:** All outputs use matching UTC timestamps for easy correlation:
240+
```
241+
dist/logs/2026-01-13-031719-UTC.json
242+
dist/reports/2026-01-13-031719-UTC.html
243+
dist/issues/GH-issue-2026-01-13-031719-UTC.md
244+
```
245+
221246
---
222247

223248
## CI/CD Integration

dist/PATTERN-LIBRARY.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": "1.0.0",
3-
"generated": "2026-01-12T16:01:47Z",
3+
"generated": "2026-01-13T03:17:30Z",
44
"summary": {
55
"total_patterns": 29,
66
"enabled": 29,

dist/PATTERN-LIBRARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Pattern Library Registry
22

33
**Auto-generated by Pattern Library Manager**
4-
**Last Updated:** 2026-01-12 16:01:47 UTC
4+
**Last Updated:** 2026-01-13 03:17:30 UTC
55

66
---
77

@@ -117,6 +117,6 @@
117117

118118
---
119119

120-
**Generated:** 2026-01-12 16:01:47 UTC
120+
**Generated:** 2026-01-13 03:17:30 UTC
121121
**Version:** 1.0.0
122122
**Tool:** Pattern Library Manager

dist/TEMPLATES/_AI_INSTRUCTIONS.md

Lines changed: 140 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,41 @@
44

55
Complete end-to-end workflow:
66
1. **Phase 1a**: Check for existing templates in `dist/TEMPLATES/`
7-
2. **Phase 1b**: Complete template if needed (extract metadata)
7+
2. **Phase 1b**: Complete template if needed (extract metadata + optional GitHub repo)
88
3. **Phase 1c**: Run scan using template or direct path
99
4. **Phase 2**: AI-assisted triage of findings
10-
11-
**IN PROGRESS - NOT READY YET:**
12-
5. **Phase 3**: Send AI confirmed issues into a single GitHub issue via GitHub CLI
13-
This will require users to setup GitHub CLI (separately from GH desktop app) and authenticate their GitHub account
10+
5. **Phase 3**: Create GitHub issue (automated or manual)
1411

1512
### End-to-End Execution Mode
1613

1714
When a user requests **"Run template [name] end to end"**, execute the complete automated pipeline:
1815

1916
1. **Run scan** → Generate JSON log (Phase 1c)
2017
2. **AI triage** → Analyze findings and update JSON (Phase 2)
21-
3. **Generate HTML** → Create final report with AI summary
18+
3. **Generate HTML** → Create final report with AI summary (Phase 2)
19+
4. **Create GitHub issue** → Automated or manual (Phase 3)
2220

2321
**No manual intervention required** - the AI agent handles all phases automatically.
2422

2523
**Example user requests:**
2624
- "Run template gravityforms end to end"
2725
- "Execute woocommerce end to end"
2826
- "Run gravityforms complete workflow"
27+
- "Scan, triage, and create GitHub issue for hypercart-helper"
2928

3029
**AI Agent Actions:**
3130
1. Execute scan: `dist/bin/run [template-name]` (wait for completion)
3231
2. Locate generated JSON: `dist/logs/[TIMESTAMP].json`
3332
3. Perform AI triage analysis (read JSON, analyze findings)
3433
4. Update JSON with `ai_triage` section
3534
5. Regenerate HTML: `python3 dist/bin/json-to-html.py [json] [html]`
36-
6. Report completion with final HTML report location
35+
6. Create GitHub issue: `dist/bin/create-github-issue.sh --scan-id [TIMESTAMP]`
36+
7. Report completion with final HTML report and GitHub issue URL (if created)
3737

3838
**Error Handling:**
3939
- If scan fails → stop and report error
40-
- If triage fails → generate basic HTML without AI summary, report issue
40+
- If triage fails → generate basic HTML without AI summary, report issue to user
41+
- If GitHub issue creation fails → issue body saved to `dist/issues/` for manual use
4142
- Provide progress updates as each phase completes
4243

4344
---
@@ -310,6 +311,137 @@ The HTML report will now show:
310311

311312
---
312313

314+
## Phase 3: GitHub Issue Creation
315+
316+
After AI triage is complete, create a GitHub issue with the findings.
317+
318+
### When to Use
319+
320+
- **Automatically**: When user requests "end to end" execution with GitHub repo configured
321+
- **Manually**: User explicitly asks "Create GitHub issue for this scan"
322+
- User wants to track findings in their project management system
323+
- User needs to share findings with their team
324+
325+
### Prerequisites
326+
327+
- ✅ Scan completed with JSON log
328+
- ✅ AI triage performed (JSON has `ai_triage` section)
329+
- ⚠️ GitHub CLI (`gh`) installed and authenticated (only for automated creation)
330+
- ⚠️ GitHub repo specified (via `--repo` flag or `GITHUB_REPO` in template) - **OPTIONAL**
331+
332+
### Workflow Steps
333+
334+
**Step 1: Determine the scan ID**
335+
```bash
336+
# Scan ID is the timestamp from the JSON filename
337+
# Example: dist/logs/2026-01-13-031719-UTC.json
338+
# Scan ID: 2026-01-13-031719-UTC
339+
```
340+
341+
**Step 2: Run the GitHub issue creator**
342+
343+
**Option A: Automated (with GitHub repo)**
344+
```bash
345+
# If template has GITHUB_REPO field
346+
./dist/bin/create-github-issue.sh --scan-id 2026-01-13-031719-UTC
347+
348+
# Or specify repo manually
349+
./dist/bin/create-github-issue.sh --scan-id 2026-01-13-031719-UTC --repo owner/repo
350+
```
351+
352+
**Option B: Manual (without GitHub repo)**
353+
```bash
354+
# No repo specified - saves to dist/issues/ for manual copy/paste
355+
./dist/bin/create-github-issue.sh --scan-id 2026-01-13-031719-UTC
356+
# → Saves to: dist/issues/GH-issue-2026-01-13-031719-UTC.md
357+
```
358+
359+
**Step 3: Handle the result**
360+
361+
**If automated creation succeeds:**
362+
- GitHub issue URL will be displayed
363+
- Issue includes:
364+
- Scan metadata (plugin/theme name, version, date)
365+
- Summary counts (confirmed issues, needs review, false positives)
366+
- Confirmed issues section with checkboxes
367+
- Needs review section with confidence levels
368+
- Local file paths to reports
369+
370+
**If no GitHub repo specified:**
371+
- Issue body saved to `dist/issues/GH-issue-{SCAN_ID}.md`
372+
- User can manually copy/paste to:
373+
- GitHub (create issue manually)
374+
- Jira, Linear, Asana, Trello, Monday.com
375+
- Internal documentation
376+
- Email or Slack
377+
378+
### Output Locations
379+
380+
All outputs use matching UTC timestamps for easy correlation:
381+
382+
```
383+
dist/logs/2026-01-13-031719-UTC.json # Scan data with AI triage
384+
dist/reports/2026-01-13-031719-UTC.html # HTML report with AI summary
385+
dist/issues/GH-issue-2026-01-13-031719-UTC.md # Issue body (if no repo)
386+
```
387+
388+
### GitHub Issue Format
389+
390+
The generated issue includes:
391+
392+
```markdown
393+
# WP Code Check Review - {SCAN_ID}
394+
395+
**Scanned:** {Date in local timezone}
396+
**Plugin/Theme:** {Name} v{Version}
397+
**Scanner Version:** {Version}
398+
399+
**Summary:** {total} findings | {confirmed} confirmed issues | {needs_review} need review | {false_positives} false positives
400+
401+
---
402+
403+
## ✅ Confirmed by AI Triage
404+
- [ ] **{Rationale}...**
405+
`{file}:{line}` | Rule: `{rule_id}`
406+
407+
---
408+
409+
## 🔍 Most Critical but Unconfirmed
410+
411+
- [ ] **{Classification} ({confidence} confidence)**
412+
`{file}:{line}` | Rule: `{rule_id}`
413+
414+
---
415+
416+
**Local Reports:**
417+
418+
```
419+
HTML Report: dist/reports/{SCAN_ID}.html
420+
JSON Report: dist/logs/{SCAN_ID}.json
421+
```
422+
423+
**Powered by:** [WPCodeCheck.com](https://wpCodeCheck.com)
424+
```
425+
426+
### Error Handling
427+
428+
| Scenario | Behavior | User Action |
429+
|----------|----------|-------------|
430+
| No GitHub repo specified | ✅ Saves to `dist/issues/` | Copy/paste manually to GitHub or PM app |
431+
| GitHub CLI not installed | ❌ Error message | Install `gh` CLI or use manual workflow |
432+
| GitHub CLI not authenticated | ❌ Error message | Run `gh auth login` |
433+
| No AI triage data | ⚠️ Warning | Run AI triage first (Phase 2) |
434+
| Invalid scan ID | ❌ Error message | Check scan ID matches JSON filename |
435+
436+
### Best Practices
437+
438+
1. **Always run AI triage first** - GitHub issues are more useful with confirmed/false positive classifications
439+
2. **Use templates with GITHUB_REPO** - Enables fully automated workflow
440+
3. **Review before creating** - Script shows preview and asks for confirmation
441+
4. **Keep issue bodies** - Files in `dist/issues/` are not tracked by Git, safe to keep for reference
442+
443+
---
444+
313445
## Common False Positive Patterns
314446

315447
| Rule ID | Common False Positive Reason |

0 commit comments

Comments
 (0)