Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 21, 2025

Summary

This PR adds a --parse flag to the audit command, bringing it into feature parity with the logs command. The flag enables optional parsing of agent logs to generate a human-readable log.md file.

Problem

Previously, the audit command always parsed agent logs automatically, which could slow down audits when log parsing wasn't needed. The logs command already had a --parse flag to make this behavior optional, but audit lacked this option.

Solution

Added a --parse flag that conditionally enables agent log parsing:

# Audit without parsing logs (default, faster)
gh aw audit 1234567890

# Audit and parse agent logs to log.md
gh aw audit 1234567890 --parse

Changes

pkg/cli/audit.go

  • Added --parse boolean flag to command definition
  • Updated AuditWorkflowRun() function signature to accept parse bool parameter
  • Wrapped the parseAgentLog() call in a conditional block based on the flag
  • Added success message when log.md is created: ✓ Parsed log for run X → path
  • Updated help text with usage example

pkg/cli/audit_test.go

  • Added TestAuditParseFlagBehavior test function
  • Validates that parse=false does NOT create log.md
  • Validates that parse=true DOES create log.md with content

Behavior

Before: Audit command always parsed agent logs (unconditional)
After: Audit command only parses agent logs when --parse is specified (default: no parsing)

This change maintains backward compatibility by making log parsing opt-in rather than automatic.

Testing

  • ✅ All existing unit tests pass
  • ✅ New test validates flag behavior for both parse=true and parse=false
  • ✅ No linting errors
  • ✅ Help text verified and consistent with logs command

Example Usage

# Basic audit (no log parsing)
gh aw audit 1234567890

# Audit with log parsing
gh aw audit 1234567890 --parse

# Combined with other flags
gh aw audit 1234567890 --parse -v
gh aw audit 1234567890 --parse -o ./audit-reports

The flag description matches the logs command exactly:

--parse    Run JavaScript parser on agent logs and write markdown to log.md
Original prompt

Add --parse option to the "audit" command, just like the "logs" command.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add parse option to audit command Add --parse option to audit command Oct 21, 2025
Copilot AI requested a review from pelikhan October 21, 2025 00:40
@pelikhan pelikhan marked this pull request as ready for review October 21, 2025 00:42
@github-actions
Copy link
Contributor

Agentic Changeset Generator triggered by this pull request.

@pelikhan pelikhan merged commit 2c1a0a3 into main Oct 21, 2025
3 checks passed
@pelikhan pelikhan deleted the copilot/add-parse-option-to-audit branch October 21, 2025 00:45
github-actions bot added a commit that referenced this pull request Oct 21, 2025
Update CLI and MCP server documentation to reflect recent feature additions:

- Add --timeout option documentation for logs command with caching details
- Add --parse option documentation for audit command
- Add URL support documentation for audit command (cross-repo, GitHub Enterprise)
- Document continuation field in MCP server logs tool for pagination
- Document large output automatic file handling in MCP server (16K token threshold)

These changes document features from PRs #2066, #2064, #2060, #2058, #2052, and #2051.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants