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.
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.
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.
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.
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.
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.
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.
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.
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.
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>
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.
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.
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.
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.
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.
Removed unnecessary conditional check for wantStdout in Test_createRun. Now always asserts equality between wantStdout and actual stdout output, improving test clarity.
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.
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.
Simplifies the error message when a repository is missing by removing the unnecessary 'error:' prefix, making the output clearer and more user-friendly.
Changed the command usage string from 'create <problem statement>' to 'create "<task description>"' for improved clarity in the agent task creation command.
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.
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.