MCPcopy Create free account
hub / github.com/github/gh-aw / NewViewCommand

Function NewViewCommand

pkg/cli/view_command.go:33–106  ·  view source on GitHub ↗

NewViewCommand creates the view command.

()

Source from the content-addressed store, hash-verified

31
32// NewViewCommand creates the view command.
33func NewViewCommand() *cobra.Command {
34 cmd := &cobra.Command{
35 Use: "view <run-id-or-url>",
36 Short: "Render unified timeline and safe outputs for a workflow run",
37 Long: `Download artifacts for a workflow run and render a unified, chronologically
38ordered activity timeline together with any safe outputs in the console.
39
40The timeline merges events from three sources:
41 - MCP Gateway logs (gateway.jsonl / rpc-messages.jsonl)
42 - AWF Firewall logs (audit.jsonl)
43 - Agent session logs (events.jsonl)
44
45The result simulates what you would see when watching a Copilot CLI session
46live, providing a readable, complete log of all agentic activity, followed
47by any safe outputs created during the run (e.g., issues, pull requests,
48comments) and a link to the GitHub Actions workflow run page.
49
50The run argument accepts the same formats as the "audit" command:
51 - A numeric run ID (e.g., 1234567890)
52 - A GitHub Actions run URL (e.g., https://github.com/owner/repo/actions/runs/1234567890)
53 - A GitHub Enterprise run URL
54
55Artifacts are downloaded to the default logs directory and cached; repeated
56invocations for the same run ID will read from the local cache without
57re-downloading.`,
58 Example: ` ` + string(constants.CLIExtensionPrefix) + ` view 1234567890
59 ` + string(constants.CLIExtensionPrefix) + ` view https://github.com/owner/repo/actions/runs/1234567890
60 ` + string(constants.CLIExtensionPrefix) + ` view 1234567890 --repo owner/repo
61 ` + string(constants.CLIExtensionPrefix) + ` view 1234567890 -o ./my-logs
62 ` + string(constants.CLIExtensionPrefix) + ` view 1234567890 -v`,
63 Args: cobra.ExactArgs(1),
64 Hidden: true,
65 RunE: func(cmd *cobra.Command, args []string) error {
66 verbose, _ := cmd.Flags().GetBool("verbose")
67 outputDir, _ := cmd.Flags().GetString("output")
68 repoFlag, _ := cmd.Flags().GetString("repo")
69
70 runIDOrURL := args[0]
71
72 components, err := parser.ParseRunURLExtended(runIDOrURL)
73 if err != nil {
74 return err
75 }
76
77 // Apply --repo flag when owner/repo were not inferred from a URL.
78 if repoFlag != "" && components.Owner == "" {
79 parts := strings.SplitN(repoFlag, "/", 2)
80 if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
81 return fmt.Errorf("invalid repository format %q: expected 'owner/repo'", repoFlag)
82 }
83 components.Owner = parts[0]
84 components.Repo = parts[1]
85 }
86
87 if outputDir == "" {
88 outputDir = defaultLogsOutputDir
89 }
90

Calls 7

ParseRunURLExtendedFunction · 0.92
ViewWorkflowRunFunction · 0.85
addOutputFlagFunction · 0.85
addRepoFlagFunction · 0.85
GetStringMethod · 0.65
ErrorfMethod · 0.45