NewLogsCommand creates the logs command
()
| 28 | |
| 29 | // NewLogsCommand creates the logs command |
| 30 | func NewLogsCommand() *cobra.Command { |
| 31 | validArtifactSets := strings.Join(ValidArtifactSetNames(), ", ") |
| 32 | |
| 33 | logsCmd := &cobra.Command{ |
| 34 | Use: "logs [workflow]", |
| 35 | Short: "Download and analyze agentic workflow logs and artifacts", |
| 36 | Long: fmt.Sprintf(`Download and analyze agentic workflow logs and artifacts from GitHub Actions. |
| 37 | |
| 38 | This command fetches workflow runs, downloads their artifacts, and extracts them into |
| 39 | organized folders named by run ID. It also provides an overview table with aggregate |
| 40 | metrics including duration, token usage, and cost information. |
| 41 | |
| 42 | By default only the compact usage artifact is downloaded (token usage, run metadata). |
| 43 | Use --artifacts all to download all artifacts, or specify individual sets such as |
| 44 | --artifacts agent,firewall to fetch only what you need. |
| 45 | |
| 46 | All available artifact sets: %s. |
| 47 | |
| 48 | Downloaded artifacts include (when using --artifacts all): |
| 49 | - Workflow metadata: Engine configuration and run metadata |
| 50 | - safe_output.jsonl: Agent's final output content (available when non-empty) |
| 51 | - agent_output/: Agent logs directory (if the workflow produced logs) |
| 52 | - agent-stdio.log: Agent standard output/error logs |
| 53 | - aw.patch: Git patch of changes made during execution (legacy; see aw-{branch}.patch) |
| 54 | - aw-{branch}.patch: Git patch of changes for each branch (one file per PR/push) |
| 55 | - workflow-logs/: GitHub Actions workflow run logs (job logs organized in subdirectory) |
| 56 | - summary.json: Complete metrics and run data for all downloaded runs |
| 57 | `, validArtifactSets) + WorkflowIDExplanation, |
| 58 | Example: ` # Basic usage |
| 59 | ` + string(constants.CLIExtensionPrefix) + ` logs # Download logs for all workflows |
| 60 | ` + string(constants.CLIExtensionPrefix) + ` logs weekly-research # Download logs for specific workflow |
| 61 | ` + string(constants.CLIExtensionPrefix) + ` logs weekly-research.md # Download logs (alternative format) |
| 62 | ` + string(constants.CLIExtensionPrefix) + ` logs -c 10 # Download last 10 matching runs |
| 63 | |
| 64 | # Date filtering |
| 65 | ` + string(constants.CLIExtensionPrefix) + ` logs --start-date 2024-01-01 # Download all runs after date |
| 66 | ` + string(constants.CLIExtensionPrefix) + ` logs --end-date 2024-01-31 # Download all runs before date |
| 67 | ` + string(constants.CLIExtensionPrefix) + ` logs --start-date -1w # Download up to 10 runs from last week |
| 68 | ` + string(constants.CLIExtensionPrefix) + ` logs --start-date -1w -c 5 # Download up to 5 runs from last week |
| 69 | ` + string(constants.CLIExtensionPrefix) + ` logs --end-date -1d # Download all runs until yesterday |
| 70 | ` + string(constants.CLIExtensionPrefix) + ` logs --start-date -1mo # Download all runs from last month |
| 71 | |
| 72 | # Content filtering |
| 73 | ` + string(constants.CLIExtensionPrefix) + ` logs --engine claude # Filter logs by claude engine |
| 74 | ` + string(constants.CLIExtensionPrefix) + ` logs --engine codex # Filter logs by codex engine |
| 75 | ` + string(constants.CLIExtensionPrefix) + ` logs --engine copilot # Filter logs by copilot engine |
| 76 | ` + string(constants.CLIExtensionPrefix) + ` logs --firewall # Filter logs with firewall enabled |
| 77 | ` + string(constants.CLIExtensionPrefix) + ` logs --no-firewall # Filter logs without firewall |
| 78 | ` + string(constants.CLIExtensionPrefix) + ` logs --safe-output missing-tool # Filter logs with missing-tool messages |
| 79 | ` + string(constants.CLIExtensionPrefix) + ` logs --safe-output missing-data # Filter logs with missing-data messages |
| 80 | ` + string(constants.CLIExtensionPrefix) + ` logs --safe-output create-issue # Filter logs with create-issue messages |
| 81 | ` + string(constants.CLIExtensionPrefix) + ` logs --safe-output noop # Filter logs with noop messages |
| 82 | ` + string(constants.CLIExtensionPrefix) + ` logs --safe-output report-incomplete # Filter logs with report-incomplete messages |
| 83 | ` + string(constants.CLIExtensionPrefix) + ` logs --ref main # Filter logs by branch or tag |
| 84 | ` + string(constants.CLIExtensionPrefix) + ` logs --ref feature-xyz # Filter logs by feature branch |
| 85 | ` + string(constants.CLIExtensionPrefix) + ` logs --filtered-integrity # Filter logs containing items that were filtered by gateway integrity checks |
| 86 | ` + string(constants.CLIExtensionPrefix) + ` logs --no-staged # Exclude staged workflow runs from results |
| 87 |