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

Function NewTrialCommand

pkg/cli/trial_command.go:11–131  ·  view source on GitHub ↗

NewTrialCommand creates the trial command

(validateEngine func(string) error)

Source from the content-addressed store, hash-verified

9
10// NewTrialCommand creates the trial command
11func NewTrialCommand(validateEngine func(string) error) *cobra.Command {
12 cmd := &cobra.Command{
13 Use: "trial <workflow-spec>...",
14 Short: "Run one or more agentic workflows in trial mode against a simulated repository",
15 Long: `Run one or more agentic workflows in trial mode against a simulated repository.
16
17This command creates a temporary private repository in your GitHub account, installs the specified
18workflow(s) from their source repositories, and runs them in "trial mode" to capture safe outputs without
19making actual changes to the "simulated" host repository.
20
21Repository modes:
22- Default mode (no flags): Creates a temporary trial repository and simulates execution as if running against the current repository (github.repository context points to current repo)
23- --logical-repo REPO: Simulates execution against a specified repository (github.repository context points to REPO while actually running in a temporary trial repository)
24- --host-repo REPO: Uses the specified repository as the host for trial execution instead of creating a temporary one
25- --clone-repo REPO: Clones the specified repository's contents into the trial repository before execution (useful for testing against actual repository state)
26
27All workflows must support workflow_dispatch trigger to be used in trial mode.
28The host repository will be created as private and kept by default unless --delete-host-repo-after is specified.
29Trial results are saved both locally (in trials/ directory) and in the host repository for future reference.`,
30 Example: ` ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/weekly-research # Run a single workflow in a temporary trial repository
31 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/daily-plan githubnext/agentics/weekly-research # Compare multiple workflows
32 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/daily-plan myorg/myrepo/custom-workflow # Run workflows from different repositories
33 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/my-workflow --host-repo myorg/myrepo # Use an existing host repository
34 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/my-workflow --logical-repo myorg/myrepo # Simulate a different github.repository value
35 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/my-workflow --clone-repo myorg/myrepo # Clone repository contents into the trial host
36 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/my-workflow --repeat 3 # Run 4 times total (1 initial + 3 repeats)
37 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/my-workflow --delete-host-repo-after # Delete the trial host repository when done
38 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/my-workflow --dry-run # Preview changes without executing
39 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/my-workflow --json # Output trial results in JSON format
40 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/my-workflow --auto-merge-prs # Auto-merge PRs created during the trial
41 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/my-workflow --host-repo . # Use the current repository as the host
42 ` + string(constants.CLIExtensionPrefix) + ` trial ./local-workflow.md --clone-repo upstream/repo --repeat 2 # Run a local workflow against cloned contents
43 ` + string(constants.CLIExtensionPrefix) + ` trial githubnext/agentics/my-workflow --trigger-context https://github.com/owner/repo/issues/123 # Provide issue context for issue-triggered workflows
44`,
45 Args: func(cmd *cobra.Command, args []string) error {
46 if len(args) < 1 {
47 return fmt.Errorf("missing workflow specification\n\nUsage:\n %s <workflow-spec>...\n\nExample:\n %[1]s githubnext/agentics/daily-plan Trial a workflow from a repository\n %[1]s ./local-workflow.md Trial a local workflow\n\nRun '%[1]s --help' for more information", cmd.CommandPath())
48 }
49 return nil
50 },
51 RunE: func(cmd *cobra.Command, args []string) error {
52 workflowSpecs := args
53 trialLog.Printf("Trial command invoked: workflow_count=%d", len(workflowSpecs))
54 logicalRepoSpec, _ := cmd.Flags().GetString("logical-repo")
55 cloneRepoSpec, _ := cmd.Flags().GetString("clone-repo")
56 hostRepoSpec, _ := cmd.Flags().GetString("host-repo")
57 deleteHostRepo, _ := cmd.Flags().GetBool("delete-host-repo-after")
58 forceDeleteHostRepo, _ := cmd.Flags().GetBool("force-delete-host-repo-before")
59 yes, _ := cmd.Flags().GetBool("yes")
60 dryRun, _ := cmd.Flags().GetBool("dry-run")
61 jsonOutput, _ := cmd.Flags().GetBool("json")
62 timeout, _ := cmd.Flags().GetInt("timeout")
63 triggerContext, _ := cmd.Flags().GetString("trigger-context")
64 repeatCount, _ := cmd.Flags().GetInt("repeat")
65 autoMergePRs, _ := cmd.Flags().GetBool("auto-merge-prs")
66 engineOverride, _ := cmd.Flags().GetString("engine")
67 appendText, _ := cmd.Flags().GetString("append")
68 verbose, _ := cmd.Root().PersistentFlags().GetBool("verbose")

Calls 9

validateEngineFunction · 0.85
RunWorkflowTrialsFunction · 0.85
addEngineFlagFunction · 0.85
addJSONFlagFunction · 0.85
GetStringMethod · 0.65
ErrorfMethod · 0.45
PrintfMethod · 0.45
EnabledMethod · 0.45
StringMethod · 0.45