|
4 | 4 |
|
5 | 5 | Complete end-to-end workflow: |
6 | 6 | 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) |
8 | 8 | 3. **Phase 1c**: Run scan using template or direct path |
9 | 9 | 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) |
14 | 11 |
|
15 | 12 | ### End-to-End Execution Mode |
16 | 13 |
|
17 | 14 | When a user requests **"Run template [name] end to end"**, execute the complete automated pipeline: |
18 | 15 |
|
19 | 16 | 1. **Run scan** → Generate JSON log (Phase 1c) |
20 | 17 | 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) |
22 | 20 |
|
23 | 21 | **No manual intervention required** - the AI agent handles all phases automatically. |
24 | 22 |
|
25 | 23 | **Example user requests:** |
26 | 24 | - "Run template gravityforms end to end" |
27 | 25 | - "Execute woocommerce end to end" |
28 | 26 | - "Run gravityforms complete workflow" |
| 27 | +- "Scan, triage, and create GitHub issue for hypercart-helper" |
29 | 28 |
|
30 | 29 | **AI Agent Actions:** |
31 | 30 | 1. Execute scan: `dist/bin/run [template-name]` (wait for completion) |
32 | 31 | 2. Locate generated JSON: `dist/logs/[TIMESTAMP].json` |
33 | 32 | 3. Perform AI triage analysis (read JSON, analyze findings) |
34 | 33 | 4. Update JSON with `ai_triage` section |
35 | 34 | 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) |
37 | 37 |
|
38 | 38 | **Error Handling:** |
39 | 39 | - 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 |
41 | 42 | - Provide progress updates as each phase completes |
42 | 43 |
|
43 | 44 | --- |
@@ -310,6 +311,137 @@ The HTML report will now show: |
310 | 311 |
|
311 | 312 | --- |
312 | 313 |
|
| 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 | + |
313 | 445 | ## Common False Positive Patterns |
314 | 446 |
|
315 | 447 | | Rule ID | Common False Positive Reason | |
|
0 commit comments