Commit graph

48 commits

Author SHA1 Message Date
Kynan Ware
44653c5aeb Add example for --custom-agent usage
Added a usage example to the help text demonstrating how to create a task with a custom agent using the --custom-agent flag.
2025-10-31 16:18:10 -06:00
Kynan Ware
0dcb1d1e43 Add shorthand flag for custom-agent option
Introduces the '-a' shorthand for the --custom-agent flag in the agent-task create command, improving CLI usability.
2025-10-31 15:59:23 -06:00
Kynan Ware
64de314640 Clarify custom agent flag description
Updated the help text for the --custom-agent flag to provide an example usage, making it clearer how to specify a custom agent for the task.
2025-10-31 15:10:03 -06:00
Kynan Ware
17085d3c5e Add custom agent support to job creation
Introduces a 'customAgent' parameter to the CreateJob API, CLI options, and related mocks and tests.
2025-10-31 14:57:48 -06:00
Kynan Ware
91c6bc609a Add new displaying message to test expectation
Updated the Test_createRun test to expect a message indicating that session logs are being displayed for the job
2025-10-07 23:37:43 -06:00
Kynan Ware
a78bb5e899 Fix --follow not killing the progress indicator
Fixes --follow not stopping the progress indicator. Also includes a nice message to indicate what is happening because even after we create the agent task, there's a period of time where we poll and receive nothing as the task session starts. We want there to be some sort of feedback in that period of time to not make the user panic and think it has hanged.
2025-10-07 23:19:45 -06:00
Babak K. Shandiz
863329b4c1
fix(agent-task create): block empty problem statement arg
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-18 14:14:59 +01:00
Babak K. Shandiz
c7a811e567
fix(agent-task create): use pager when following logs
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-18 13:55:37 +01:00
Babak K. Shandiz
cb9808fa6e
fix(agent-task create): avoid prompting when problem statement is provided
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-18 13:51:13 +01:00
Babak K. Shandiz
dab285c61a
test(agent-task create): add test for --follow
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-16 13:27:39 +01:00
Babak K. Shandiz
f5ed563a42
docs(agent-task create): add example for --follow flag
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-16 13:18:26 +01:00
Babak K. Shandiz
4f7d577b97
feat(agent-task create): add --follow flag
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-16 13:18:09 +01:00
Babak K. Shandiz
134ae31fea
refactor(agent-task create): extract session URL polling into a func
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-16 13:07:01 +01:00
Kynan Ware
3831380d13 Add error type assertion to createRun tests
Introduces a new 'wantErrIs' field to test cases in Test_createRun to assert specific error types using require.ErrorIs. This enhances test coverage by verifying not only error messages but also error types.
2025-09-11 11:23:18 -06:00
Kynan Ware
1dbb694790 Add test for non-interactive problem statement input
Adds a test case to ensure that when a problem statement is provided as an argument non-interactively, the command does not prompt or return an error, and the correct job is created.
2025-09-11 09:24:42 -06:00
Kynan Ware
f22dc9271b Update test to use edited task description
Modified the test in create_test.go to return and expect 'edited task description' instead of concatenating the prompt string. This clarifies the test's intent and expected behavior for the MarkdownEditorFunc and CreateJobFunc.
2025-09-11 09:22:27 -06:00
Kynan Ware
666f5574e4 Remove unused stdin field from create command tests
The 'stdin' field and related code were removed from TestNewCmdCreate as they were no longer used. This simplifies the test structure and eliminates unnecessary code.
2025-09-11 09:20:48 -06:00
Kynan Ware
872cf495c2 Refactor create command tests and add base branch case
Removed redundant test cases for file input and stdin in TestNewCmdCreate, and added a new test to verify that the base branch argument sets the BaseBranch field correctly.
2025-09-11 09:19:52 -06:00
Kynan Ware
deee0c61ed Update command examples for agent-task create
Improves the help text for the 'gh agent-task create' command by clarifying the editor usage example and adding an example for using a file as a template.
2025-09-10 18:39:35 -06:00
Kynan Ware
c0a5b9aced Refactor agent-task create to improve file input handling
Moves file reading for the problem statement from argument parsing to execution, storing the file path in CreateOptions. Updates error handling and user prompts to better distinguish between interactive and non-interactive modes. Refactors and expands tests to match the new logic and improve coverage for file and prompt scenarios.
2025-09-10 18:19:12 -06:00
Babak K. Shandiz
4cebd35791
refactor(agent-task create): assign Config at instantiation
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-10 12:48:31 +01:00
Babak K. Shandiz
b463395d48
fix(agent-task create): only prompt for problem statement if not provided
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-10 12:45:34 +01:00
Kynan Ware
6945fc0183 Still prompt for task desc with -F 2025-09-09 17:08:04 -06:00
Kynan Ware
563809362b Add interactive prompt for task description in agent-task create
Enhances the agent-task create command to prompt users for a task description interactively if none is provided and the terminal supports prompting. Updates tests to cover interactive and non-interactive scenarios, including error handling for empty input and prompt failures.
2025-09-09 16:19:52 -06:00
Babak K. Shandiz
004be9da20
test(agent-task create): quote file paths to pass CI on Windows
To keep the backslashes in Windows file paths and stop `shlex.Split`
from interpreting them as escape characters, we need to quote the paths.

Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-05 09:28:52 +01:00
Babak K. Shandiz
844c0ab56e
refactor(agent-task create): remove redundant if
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 21:06:15 +01:00
Babak K. Shandiz
07ec8c629d
test(agent-task create): use CapiClientMock
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 21:01:56 +01:00
Babak K. Shandiz
28bb0f62bb
fix(agent-task create): simplify command initialisation
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 20:59:33 +01:00
Babak K. Shandiz
d17fdb3e8c
test(agent-task list): update TestNewCmdCreate
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 20:19:35 +01:00
Babak K. Shandiz
b0ac06e4f4
fix(agent-task create): allow no positional arg
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 20:17:43 +01:00
Babak K. Shandiz
f3c3797d5c
refactor(agent-task list): use shared CapiClientFunc
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-04 20:12:53 +01:00
Kynan Ware
28a7daee40 Improve agent-task create command help text
Expanded usage examples in the command help to clarify reading from stdin and selecting a base branch. Updated flag descriptions for --from-file and --base to provide clearer guidance to users.
2025-09-04 11:13:21 -06:00
Kynan Ware
3c3b5669f1 Refactor test case struct in create_test.go
Replaces custom 'tc' type with an inline struct for test cases in TestNewCmdCreate_Args, simplifying the test code structure.
2025-09-03 17:35:17 -06:00
Kynan Ware
b2f506fd50 Add base branch option to agent task creation
Introduces a BaseBranch field to CreateOptions and updates the job creation flow to include the base branch in the payload if specified. The CapiClient and related methods are updated to accept and handle the baseBranch parameter, and tests are added to verify correct behavior when a base branch is provided.
2025-09-03 17:33:38 -06:00
Kynan Ware
8af1787b31 Support reading task description from stdin
Refactored file reading in agent-task create command to use cmdutil.ReadFile, allowing input from stdin. Updated tests to cover reading file content from stdin and improved test setup for file and stdin input cases.
2025-09-03 15:52:45 -06:00
Kynan Ware
9dfe89fe50 Increase backoff timing for agent task creation
Extended the max elapsed time and max interval for the exponential backoff strategy in agent task creation to improve reliability during retries.
2025-09-03 15:29:47 -06:00
Kynan Ware
b94ffe90c4 Add file input support to agent-task create command
The agent-task create command now accepts a task description from a file using the -F/--from-file flag, with mutual exclusivity enforced between inline and file input. Tests were updated to cover new input scenarios and error cases, and usage examples were added to the command help.
2025-09-03 15:29:47 -06:00
Kynan Ware
a821b408d4 Update error messages and test repo handling in agent-task create
Replaces 'problem statement' with 'task description' in error messages for clarity. Refactors tests to use a BaseRepo function instead of direct repo objects, and adds a test for missing task description error.
2025-09-03 14:25:38 -06:00
Kynan Ware
44e81b021c Simplify stdout assertion in createRun test
Removed unnecessary conditional check for wantStdout in Test_createRun. Now always asserts equality between wantStdout and actual stdout output, improving test clarity.
2025-09-03 12:36:12 -06:00
Kynan Ware
32bf9159ea Improve job error handling and update tests
Normalizes job API error messages to include status code and text, ensures errors from job polling are surfaced to stderr without halting execution, and updates tests to verify error output and remove outdated fallback behavior.
2025-09-03 12:34:13 -06:00
Kynan Ware
33d1196645 Escape URL path segments in agent session links
Uses url.PathEscape for repo owner, repo name, and session ID when constructing agent session URLs to ensure proper encoding and prevent issues with special characters.
2025-09-03 10:40:00 -06:00
Kynan Ware
c3bbd374aa Remove nil check for job in agentSessionWebURL
Simplifies the agentSessionWebURL function by removing the redundant nil check for the job parameter, assuming it is always non-nil when called.
2025-09-03 10:33:31 -06:00
Kynan Ware
3d8d5f3e31 Update test to expect 500 error response
Changed the mocked API response status from 400 to 500 in Test_createRun to better reflect the expected error scenario.
2025-09-03 10:29:38 -06:00
Kynan Ware
2bec2bcf65 Update error message in createRun test
Removed 'error:' prefix from expected error message in the 'missing repo returns error' test case for consistency with actual output.
2025-09-03 10:28:39 -06:00
Kynan Ware
3a7465ed96 Remove redundant 'error:' prefix from repo error
Simplifies the error message when a repository is missing by removing the unnecessary 'error:' prefix, making the output clearer and more user-friendly.
2025-09-03 10:26:58 -06:00
Kynan Ware
a81cff3fdf Update command usage for agent task creation
Changed the command usage string from 'create <problem statement>' to 'create "<task description>"' for improved clarity in the agent task creation command.
2025-09-03 10:06:30 -06:00
Kynan Ware
a3fa83071d Update agent-task create command argument handling
Changed argument parsing to accept a maximum of one argument and assign it directly to ProblemStatement. Added error handling for missing problem statement and removed unused strings import.
2025-09-03 10:03:48 -06:00
Kynan Ware
3574ee9c30 Add agent task creation command and job API
Introduces the 'create' subcommand for agent tasks, allowing users to create agent jobs via the Copilot API. Adds job API client methods, job model, and polling logic to retrieve associated pull requests. Includes tests for various job creation scenarios.
2025-09-02 20:42:39 -06:00