From 1bcc701fbbfe0e2f476a19c6b7bfeeb0a99d38b4 Mon Sep 17 00:00:00 2001 From: Dimitrios Philliou Date: Fri, 20 Sep 2024 12:10:07 -0700 Subject: [PATCH 01/10] Adding docs links to README.md Adding links to builder docs --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index e74cdf6..029a1b1 100644 --- a/README.md +++ b/README.md @@ -126,3 +126,10 @@ Be ye sure ye want a custom limerick 'bout petals ? Reply: [y/N] ``` 8. Currently, the supported event types for debug mode are references, errors, and confirmations! Have fun chatting with your assistant! + +## Copilot Extensions Documentation +- [Using Copilot Extensions](https://docs.github.com/en/copilot/using-github-copilot/using-extensions-to-integrate-external-tools-with-copilot-chat) +- [About building Copilot Extensions](https://docs.github.com/en/copilot/building-copilot-extensions/about-building-copilot-extensions) +- [Set up process](https://docs.github.com/en/copilot/building-copilot-extensions/setting-up-copilot-extensions) +- [Communicating with the Copilot platform](https://docs.github.com/en/copilot/building-copilot-extensions/building-a-copilot-agent-for-your-copilot-extension/configuring-your-copilot-agent-to-communicate-with-the-copilot-platform) +- [Communicating with GitHub](https://docs.github.com/en/copilot/building-copilot-extensions/building-a-copilot-agent-for-your-copilot-extension/configuring-your-copilot-agent-to-communicate-with-github) From 81242a49550040ede20b29d7df1443a15e561890 Mon Sep 17 00:00:00 2001 From: calvinmvrk Date: Tue, 12 Nov 2024 12:48:33 -0600 Subject: [PATCH 02/10] update stream cmd logic and error handling --- cmd/stream.go | 3 ++- pkg/stream/parse.go | 13 +++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/stream.go b/cmd/stream.go index 24bf21b..b0585dc 100644 --- a/cmd/stream.go +++ b/cmd/stream.go @@ -30,9 +30,10 @@ func agentStream(cmd *cobra.Command, args []string) { file := args[0] - err := stream.ParseFile(file) + result, err := stream.ParseFile(file) if err != nil { fmt.Fprintf(os.Stderr, "Error parsing file: %v\n", err) os.Exit(1) } + fmt.Println(result) } diff --git a/pkg/stream/parse.go b/pkg/stream/parse.go index e1929ae..01ba78f 100644 --- a/pkg/stream/parse.go +++ b/pkg/stream/parse.go @@ -18,11 +18,11 @@ type Data struct { Choices []Choice `json:"choices"` } -func ParseFile(filename string) error { +func ParseFile(filename string) (string, error) { // Open the file file, err := os.Open(filename) if err != nil { - return fmt.Errorf("could not open file: %w", err) + return "", fmt.Errorf("could not open file: %w", err) } defer file.Close() @@ -52,8 +52,7 @@ func ParseFile(filename string) error { var data Data err := json.Unmarshal([]byte(line), &data) if err != nil { - // Skip this line if JSON is incomplete or malformed - continue + return "", fmt.Errorf("error parsing JSON: %w", err) } // Extract delta.content and concatenate it @@ -64,12 +63,10 @@ func ParseFile(filename string) error { // Check for scanner errors if err := scanner.Err(); err != nil { - return fmt.Errorf("error reading file: %w", err) + return "", fmt.Errorf("error reading file: %w", err) } // Print the final concatenated result result := contentBuilder.String() - fmt.Println(result) - - return nil + return result, nil } From 821a5f659637847c859aba637966944d568233a8 Mon Sep 17 00:00:00 2001 From: calvinmvrk Date: Mon, 18 Nov 2024 12:23:02 -0600 Subject: [PATCH 03/10] update readme --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e74cdf6..8062d59 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The different SSE events in the [agent protocol](TODO) that the CLI gives debug gh debug-cli -h ``` -## Using the debug tool +## Using the debug chat tool 1. Run the following command `gh debug-cli -h` to see the different flags that it takes in. ``` > gh debug-cli -h @@ -126,3 +126,16 @@ Be ye sure ye want a custom limerick 'bout petals ? Reply: [y/N] ``` 8. Currently, the supported event types for debug mode are references, errors, and confirmations! Have fun chatting with your assistant! + + +## Using the debug stream tool +1. to quickly parse agent response run cmd go run `main.go stream [local file name]` for example `gh-debug-cli stream test.txt` + +2. tool will take print out data packet for easy readability +``` +data: {"choices":[{"delta":{"content":"A closure in JavaScript "}}],"created":1727120830,"id":"chatcmpl-AAjJW0Nz9E2Gu1P6YQMFqqmn10mdR","model":"gpt-4o-2024-05-13","system_fingerprint":"fp_80a1bad4c7"} +data: {"choices":[{"delta":{"content":"is a function that retains access "}}],"created":1727120831,"id":"chatcmpl-AAjJW0Nz9E2Gu1P6YQMFqqmn10mdR","model":"gpt-4o-2024-05-13","system_fingerprint":"fp_80a1bad4c7"} +data: {"choices":[{"delta":{"content":"to its lexical scope, even "}}],"created":1727120832,"id":"chatcmpl-AAjJW0Nz9E2Gu1P6YQMFqqmn10mdR","model":"gpt-4o-2024-05-13","system_fingerprint":"fp_80a1bad4c7"} +data: {"choices":[{"delta":{"content":"when the function is executed "}}],"created":1727120833,"id":"chatcmpl-AAjJW0Nz9E2Gu1P6YQMFqqmn10mdR","model":"gpt-4o-2024-05-13","system_fingerprint":"fp_80a1bad4c7"} +data: {"choices":[{"delta":{"content":"outside that scope. "}}],"created":1727120834,"id":"chatcmpl-AAjJW0Nz9E2Gu1P6YQMFqqmn10mdR","model":"gpt-4o-2024-05-13","system_fingerprint":"fp_80a1bad4c7"} +``` \ No newline at end of file From cfbacdbf988ee6494c4f3bd0f98b54cfaefec666 Mon Sep 17 00:00:00 2001 From: calvinmvrk Date: Tue, 19 Nov 2024 15:55:43 -0600 Subject: [PATCH 04/10] refactor stream cmd --- cmd/stream.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/stream.go b/cmd/stream.go index b0585dc..3083a44 100644 --- a/cmd/stream.go +++ b/cmd/stream.go @@ -15,20 +15,25 @@ const ( // streamCmd represents the new command for streaming functionality var streamCmd = &cobra.Command{ - Use: "stream [file]", - Short: "Stream data to your agent", - Long: `The stream command allows you to initiate a data stream to your agent.`, + Use: "stream --file [filename]", + Short: "Parse stream data from agent", + Long: `Allows you to parse a data stream to your agent response.`, Run: agentStream, } func init() { streamCmd.PersistentFlags().String(streamCmdFileFlag, "", "Parse agent responses from a file") + rootCmd.AddCommand(streamCmd) } func agentStream(cmd *cobra.Command, args []string) { fmt.Println("stream command executed successfully") - file := args[0] + file, _ := cmd.Flags().GetString(streamCmdFileFlag) + if file == "" { + fmt.Fprintln(os.Stderr, "Error: --file [file] is required") + os.Exit(1) + } result, err := stream.ParseFile(file) if err != nil { From fa038cd265fb185bba9b3ec68ba50b0005a14bff Mon Sep 17 00:00:00 2001 From: calvinmvrk Date: Wed, 20 Nov 2024 10:16:10 -0600 Subject: [PATCH 05/10] remove unused cmd --- cmd/stream.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/stream.go b/cmd/stream.go index 3083a44..6677a16 100644 --- a/cmd/stream.go +++ b/cmd/stream.go @@ -23,7 +23,7 @@ var streamCmd = &cobra.Command{ func init() { streamCmd.PersistentFlags().String(streamCmdFileFlag, "", "Parse agent responses from a file") - rootCmd.AddCommand(streamCmd) + // rootCmd.AddCommand(streamCmd) } func agentStream(cmd *cobra.Command, args []string) { From 9db4d49b6429bfdd278b57e31a41ee0613eefb6d Mon Sep 17 00:00:00 2001 From: calvinmvrk Date: Wed, 20 Nov 2024 16:22:56 -0600 Subject: [PATCH 06/10] remove commented line --- cmd/stream.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/stream.go b/cmd/stream.go index 6677a16..1d90fda 100644 --- a/cmd/stream.go +++ b/cmd/stream.go @@ -23,7 +23,6 @@ var streamCmd = &cobra.Command{ func init() { streamCmd.PersistentFlags().String(streamCmdFileFlag, "", "Parse agent responses from a file") - // rootCmd.AddCommand(streamCmd) } func agentStream(cmd *cobra.Command, args []string) { From ebea4565b3a47d26c9bac044b92bfa052caeb5e5 Mon Sep 17 00:00:00 2001 From: calvinmvrk Date: Wed, 20 Nov 2024 17:21:32 -0600 Subject: [PATCH 07/10] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8062d59..43e4c19 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ Reply: [y/N] ## Using the debug stream tool -1. to quickly parse agent response run cmd go run `main.go stream [local file name]` for example `gh-debug-cli stream test.txt` +1. to quickly parse agent response run cmd go run `main.go stream --file [local file name]` for example `gh-debug-cli stream --file test.txt` 2. tool will take print out data packet for easy readability ``` From 7481688a505af5b580952c79e29d784bf289964e Mon Sep 17 00:00:00 2001 From: calvinmvrk Date: Thu, 21 Nov 2024 14:05:45 -0600 Subject: [PATCH 08/10] update help logic --- cmd/rootCmd.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/rootCmd.go b/cmd/rootCmd.go index 64b6c1a..dfc28b3 100644 --- a/cmd/rootCmd.go +++ b/cmd/rootCmd.go @@ -9,11 +9,10 @@ import ( ) var rootCmd = &cobra.Command{ - Use: "gh-debug-cli", Short: "A CLI tool for debugging", Long: `This CLI tool allows you to debug your agent by chatting with it locally.`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("Use 'gh-debug-cli --help' to see available commands") + // fmt.Println("Use 'gh debug-cli --help' to see available commands") }, } From 9470d1ffab070f955bb3afbc49aa8321d2619460 Mon Sep 17 00:00:00 2001 From: calvinmvrk Date: Thu, 21 Nov 2024 14:09:06 -0600 Subject: [PATCH 09/10] remove commented line in run cmd --- cmd/rootCmd.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/rootCmd.go b/cmd/rootCmd.go index dfc28b3..f7cb407 100644 --- a/cmd/rootCmd.go +++ b/cmd/rootCmd.go @@ -12,7 +12,6 @@ var rootCmd = &cobra.Command{ Short: "A CLI tool for debugging", Long: `This CLI tool allows you to debug your agent by chatting with it locally.`, Run: func(cmd *cobra.Command, args []string) { - // fmt.Println("Use 'gh debug-cli --help' to see available commands") }, } From 7c1d482b15940cece752c90615eaedb9ab21bf82 Mon Sep 17 00:00:00 2001 From: calvinmvrk Date: Thu, 21 Nov 2024 14:19:23 -0600 Subject: [PATCH 10/10] update readme --- README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 43e4c19..021d30e 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,13 @@ The different SSE events in the [agent protocol](TODO) that the CLI gives debug ``` 1. See more info about the cli tool ```shell - gh debug-cli -h + gh debug-cli chat -h ``` ## Using the debug chat tool -1. Run the following command `gh debug-cli -h` to see the different flags that it takes in. +1. Run the following command `gh debug-cli chat -h` to see the different flags that it takes in. ``` -> gh debug-cli -h +> gh debug-cli chat -h This cli tool allows you to debug your agent by chatting with it locally. Usage: @@ -47,7 +47,7 @@ export URL="http://localhost:8080/agent/blackbeard" ``` 3. When you run the CLI, you will see any flags that were previously set in your environment variables as the output. ``` -> gh debug-cli +> gh debug-cli chat Setting url to http://localhost:8080/agents/blackbeard Start typing to chat with your assistant... @@ -55,7 +55,7 @@ sparklyunicorn: ``` 4. Type something to simulate chatting with your assistant. ``` -> gh debug-cli +> gh debug-cli chat Setting url to http://localhost:8080/agents/blackbeard Start typing to chat with your assistant... @@ -114,7 +114,7 @@ assistant: Avast, @monalisa! Me apologies if I didn't quite understand yer reque ``` 7. And if debug mode was set to false, then I would only see the confirmation prompt itself. ``` -gh debug-cli --log-level none +gh debug-cli chat --log-level none Setting url to http://localhost:8080/agents/blackbeard Start typing to chat with your assistant... @@ -128,10 +128,14 @@ Reply: [y/N] 8. Currently, the supported event types for debug mode are references, errors, and confirmations! Have fun chatting with your assistant! -## Using the debug stream tool -1. to quickly parse agent response run cmd go run `main.go stream --file [local file name]` for example `gh-debug-cli stream --file test.txt` +## Using the gh debug stream tool +1. To quickly parse an agent response by running command `gh debug-cli stream --file test.txt` + +2. This tool will take llm streaming response and parse it to make it more readable -2. tool will take print out data packet for easy readability + - In this example, if a file test.txt holds the following streamed response. Then will return the response "A closure in JavaScript is a function that retains access... " This will make repsonse more readable. + +example of .txt file ``` data: {"choices":[{"delta":{"content":"A closure in JavaScript "}}],"created":1727120830,"id":"chatcmpl-AAjJW0Nz9E2Gu1P6YQMFqqmn10mdR","model":"gpt-4o-2024-05-13","system_fingerprint":"fp_80a1bad4c7"} data: {"choices":[{"delta":{"content":"is a function that retains access "}}],"created":1727120831,"id":"chatcmpl-AAjJW0Nz9E2Gu1P6YQMFqqmn10mdR","model":"gpt-4o-2024-05-13","system_fingerprint":"fp_80a1bad4c7"}