Add chat command by scalvert · Pull Request #3 · gleanwork/glean-cli

Summary

This pull request introduces a new chat command to the glean-cli and includes several other improvements and refactorings. The most important changes are the addition of the chat command, associated tests, and improvements to the command structure and error handling.

New Chat Command:

  • cmd/chat.go: Added a new chat command that allows users to have conversations with Glean's chat API. This includes defining new types (ChatMessage, ChatRequest, ChatResponse, AgentConfig), implementing the NewCmdChat function, and the chat execution logic (executeChat).

Tests for Chat Command:

  • cmd/chat_test.go: Added comprehensive tests for the new chat command, covering basic responses, error handling, invalid JSON, empty responses, and different flag options.

Command Structure Improvements:

  • cmd/root.go: Added the new chat command to the root command, silenced usage output and errors for consistent error formatting, and propagated these settings to all subcommands. [1] [2]

Error Handling Enhancements:

  • cmd/root.go: Modified the Execute function to print errors to stderr and return the error.

Refactoring and Cleanup:

  • cmd/search.go: Refactored the search command by reorganizing types and constants, and improving the structure of the NewCmdSearch function. [1] [2] [3] [4] [5] [6]