├── CODE_OF_CONDUCT.md ├── LICENSE.txt ├── README.md ├── SECURITY.md ├── SUPPORT.md ├── go.mod ├── handlers ├── commit_message.go ├── loripsum.go └── user.go └── main.go /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at . All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright GitHub, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Skillset Example 2 | 3 | ## Description 4 | 5 | This code sample demonstrates building a Copilot Extension using the skillsets approach rather than a traditional agent. This extension is designed to generate random test and example data for a number of development purposes, by calling publicly available APIs. 6 | 7 | ### Architectural Model 8 | - **Skillsets**: Define up to 5 API endpoints that Copilot can call directly. Copilot handles all AI interactions, prompt engineering, and response formatting. 9 | - **Agents**: Provide full control over the interaction flow, including custom prompt crafting and specific LLM model selection. 10 | 11 | ![Architectural comparison between Skillsets and Agents](https://github.com/user-attachments/assets/9c5d6489-afb5-47c2-be73-2561d89dfde3) 12 | 13 | 14 | ### When to Choose Skillsets 15 | Skillsets are ideal when you want to: 16 | - Quickly integrate existing APIs or services without managing AI logic 17 | - Focus purely on your service's core functionality 18 | - Maintain consistent Copilot-style interactions without extensive development 19 | - Get started with minimal infrastructure and setup 20 | 21 | Use agents instead if you need: 22 | - Complex custom interaction flows 23 | - Specific LLM model control (using LLMs that aren't provided by the Copilot API) 24 | - Custom prompt crafting 25 | - Advanced state management 26 | 27 | ## Example Implementation 28 | 29 | This extension showcases the skillset approach by providing three simple endpoints that generate random development data: 30 | - Random commit messages 31 | - Lorem ipsum text generation 32 | - Random user data 33 | 34 | ## Getting Started 35 | 1. Clone the repository: 36 | 37 | ``` 38 | git clone git@github.com:copilot-extensions/skillset-example.git 39 | cd skillset-example 40 | ``` 41 | 42 | 2. Install dependencies: 43 | 44 | ``` 45 | go mod tidy 46 | ``` 47 | 48 | ## Usage 49 | 50 | 1. Start up ngrok with the port provided: 51 | 52 | ``` 53 | ngrok http http://localhost:8080 54 | ``` 55 | 56 | 2. Set the environment variables (use the ngrok generated url for the `FDQN`) 57 | 3. Run the application: 58 | 59 | ``` 60 | go run . 61 | ``` 62 | 63 | ## Accessing the Extension in Chat: 64 | 65 | 1. In the `Copilot` tab of your Application settings (`https://github.com/settings/apps//agent`) 66 | - Set the app type to "Skillset" 67 | - Specify the following skills 68 | ``` 69 | Name: random_commit_message 70 | Inference description: Generates a random commit message 71 | URL: https:///random-commit-message 72 | Parameters: { "type": "object" } 73 | Return type: String 74 | --- 75 | Name: random_lorem_ipsum 76 | Inference description: Generates a random Lorem Ipsum text. Responses should have html tags present. 77 | URL: https:///random-lorem-ipsum 78 | Parameters: 79 | { 80 | "type": "object", 81 | "properties": { 82 | "number_of_paragraphs": { 83 | "type": "number", 84 | "description": "The number of paragraphs to be generated. Must be between 1 and 10 inclusive" 85 | }, 86 | "paragraph_length": { 87 | "type": "string", 88 | "description": "The length of each paragraph. Must be one of \"short\", \"medium\", \"long\", or \"verylong\"" 89 | } 90 | } 91 | } 92 | Return type: String 93 | --- 94 | Name: random_user 95 | Inference description: Generates data for a random user 96 | URL: https:///random-user 97 | Parameters: { "type": "object" } 98 | Return type: String 99 | ``` 100 | 101 | 2. In the `General` tab of your application settings (`https://github.com/settings/apps/`) 102 | - Set the `Callback URL` to anything (`https://github.com` works well for testing, in a real environment, this would be a URL you control) 103 | - Set the `Homepage URL` to anything as above 104 | 3. Ensure your permissions are enabled in `Permissions & events` > 105 | - `Account Permissions` > `Copilot Chat` > `Access: Read Only` 106 | 4. Ensure you install your application at (`https://github.com/apps/`) 107 | 5. Now if you go to `https://github.com/copilot` you can `@` your skillset extension using the name of your app. 108 | 109 | ## What can the bot do? 110 | 111 | Here's some example things: 112 | 113 | * `@skillset-example please create a random commit message` 114 | * `@skillset-example generate a lorem ipsum` 115 | * `@skillset-example generate a short lorem ipsum with 3 paragraphs` 116 | * `@skillset-example generate random user data` 117 | 118 | ## Implementation 119 | 120 | This bot provides a passthrough to a couple of other APIs: 121 | 122 | * For commit messages, https://whatthecommit.com/ 123 | * For Lorem Ipsum, https://loripsum.net/ 124 | * For user data, https://randomuser.me/ 125 | 126 | ## Documentation 127 | - [Using Copilot Extensions](https://docs.github.com/en/copilot/using-github-copilot/using-extensions-to-integrate-external-tools-with-copilot-chat) 128 | - [About skillsets](https://docs.github.com/en/copilot/building-copilot-extensions/building-a-copilot-skillset-for-your-copilot-extension/about-copilot-skillsets) 129 | - [About building Copilot Extensions](https://docs.github.com/en/copilot/building-copilot-extensions/about-building-copilot-extensions) 130 | - [Set up process](https://docs.github.com/en/copilot/building-copilot-extensions/setting-up-copilot-extensions) 131 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | Thanks for helping make GitHub safe for everyone. 2 | 3 | # Security 4 | 5 | GitHub takes the security of our software products and services seriously, including all of the open source code repositories managed through our GitHub organizations, such as [GitHub](https://github.com/GitHub). 6 | 7 | Even though [open source repositories are outside of the scope of our bug bounty program](https://bounty.github.com/index.html#scope) and therefore not eligible for bounty rewards, we will ensure that your finding gets passed along to the appropriate maintainers for remediation. 8 | 9 | ## Reporting Security Issues 10 | 11 | If you believe you have found a security vulnerability in any GitHub-owned repository, please report it to us through coordinated disclosure. 12 | 13 | **Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.** 14 | 15 | Instead, please send an email to opensource-security[@]github.com. 16 | 17 | Please include as much of the information listed below as you can to help us better understand and resolve the issue: 18 | 19 | * The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting) 20 | * Full paths of source file(s) related to the manifestation of the issue 21 | * The location of the affected source code (tag/branch/commit or direct URL) 22 | * Any special configuration required to reproduce the issue 23 | * Step-by-step instructions to reproduce the issue 24 | * Proof-of-concept or exploit code (if possible) 25 | * Impact of the issue, including how an attacker might exploit the issue 26 | 27 | This information will help us triage your report more quickly. 28 | 29 | ## Policy 30 | 31 | See [GitHub's Safe Harbor Policy](https://docs.github.com/en/site-policy/security-policies/github-bug-bounty-program-legal-safe-harbor#1-safe-harbor-terms) -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Support 2 | 3 | ## How to file issues and get help 4 | 5 | This project uses GitHub issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new issue. 6 | 7 | - **THIS PROJECT NAME** is under active development and maintained by GitHub staff **AND THE COMMUNITY**. We will do our best to respond to support, feature requests, and community questions in a timely manner. 8 | 9 | ## GitHub Support Policy 10 | 11 | Support for this project is limited to the resources listed above. -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/github/testdatabot 2 | 3 | go 1.21.6 4 | -------------------------------------------------------------------------------- /handlers/commit_message.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "net/http" 7 | ) 8 | 9 | func CommitMessage(w http.ResponseWriter, r *http.Request) { 10 | fmt.Println("Commit Message Called") 11 | req, err := http.NewRequestWithContext(r.Context(), http.MethodGet, "https://whatthecommit.com/index.txt", nil) 12 | if err != nil { 13 | w.WriteHeader(http.StatusInternalServerError) 14 | return 15 | } 16 | 17 | resp, err := (&http.Client{}).Do(req) 18 | if err != nil { 19 | w.WriteHeader(http.StatusInternalServerError) 20 | return 21 | } 22 | defer resp.Body.Close() 23 | 24 | if resp.StatusCode != http.StatusOK { 25 | w.WriteHeader(http.StatusInternalServerError) 26 | return 27 | } 28 | 29 | if _, err := io.Copy(w, resp.Body); err != nil { 30 | fmt.Println("Something unrecoverable went wrong") 31 | return 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /handlers/loripsum.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io" 7 | "net/http" 8 | "net/url" 9 | "path" 10 | ) 11 | 12 | func Loripsum(w http.ResponseWriter, r *http.Request) { 13 | fmt.Println("Loripsum Called") 14 | 15 | params := &struct { 16 | NumberOfParagraphs int `json:"number_of_paragraphs"` 17 | ParagraphLength string `json:"paragraph_length"` 18 | Decorate bool `json:"decorate"` 19 | Link bool `json:"link"` 20 | UnorderedLists bool `json:"unordered_lists"` 21 | NumberedLists bool `json:"numbered_lists"` 22 | DescriptionLists bool `json:"description_lists"` 23 | BlockQuotes bool `json:"blockquotes"` 24 | Code bool `json:"code"` 25 | Headers bool `json:"headers"` 26 | AllCaps bool `json:"all_caps"` 27 | Prude bool `json:"prude"` 28 | }{} 29 | 30 | err := json.NewDecoder(r.Body).Decode(¶ms) 31 | if err != nil { 32 | w.WriteHeader(http.StatusBadRequest) 33 | return 34 | } 35 | 36 | p := "api" 37 | if params.NumberOfParagraphs != 0 { 38 | if params.NumberOfParagraphs < 0 { 39 | p = path.Join(p, "1") 40 | } else if params.NumberOfParagraphs > 10 { 41 | p = path.Join(p, "10") 42 | } else { 43 | p = path.Join(p, fmt.Sprintf("%v", params.NumberOfParagraphs)) 44 | } 45 | } 46 | 47 | if params.ParagraphLength == "short" || params.ParagraphLength == "medium" || params.ParagraphLength == "long" || params.ParagraphLength == "verylong" { 48 | p = path.Join(p, params.ParagraphLength) 49 | } 50 | 51 | if params.Decorate { 52 | p = path.Join(p, "decorate") 53 | } 54 | 55 | if params.Link { 56 | p = path.Join(p, "link") 57 | } 58 | 59 | if params.UnorderedLists { 60 | p = path.Join(p, "ul") 61 | } 62 | 63 | if params.NumberedLists { 64 | p = path.Join(p, "ol") 65 | } 66 | 67 | if params.DescriptionLists { 68 | p = path.Join(p, "dl") 69 | } 70 | 71 | if params.BlockQuotes { 72 | p = path.Join(p, "bq") 73 | } 74 | 75 | if params.Code { 76 | p = path.Join(p, "code") 77 | } 78 | 79 | if params.Headers { 80 | p = path.Join(p, "headers") 81 | } 82 | 83 | if params.AllCaps { 84 | p = path.Join(p, "allcaps") 85 | } 86 | 87 | if params.Prude { 88 | p = path.Join(p, "prude") 89 | } 90 | 91 | u, _ := url.Parse("https://loripsum.net") 92 | u.Path = p 93 | 94 | req, err := http.NewRequestWithContext(r.Context(), http.MethodGet, u.String(), nil) 95 | if err != nil { 96 | w.WriteHeader(http.StatusInternalServerError) 97 | return 98 | } 99 | 100 | resp, err := (&http.Client{}).Do(req) 101 | if err != nil { 102 | w.WriteHeader(http.StatusInternalServerError) 103 | return 104 | } 105 | defer resp.Body.Close() 106 | 107 | if resp.StatusCode != http.StatusOK { 108 | w.WriteHeader(http.StatusInternalServerError) 109 | return 110 | } 111 | 112 | if _, err := io.Copy(w, resp.Body); err != nil { 113 | fmt.Println("Something unrecoverable went wrong") 114 | return 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /handlers/user.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "net/http" 7 | ) 8 | 9 | func User(w http.ResponseWriter, r *http.Request) { 10 | fmt.Println("User Called") 11 | req, err := http.NewRequestWithContext(r.Context(), http.MethodGet, "https://randomuser.me/api", nil) 12 | if err != nil { 13 | w.WriteHeader(http.StatusInternalServerError) 14 | return 15 | } 16 | 17 | resp, err := (&http.Client{}).Do(req) 18 | if err != nil { 19 | w.WriteHeader(http.StatusInternalServerError) 20 | return 21 | } 22 | defer resp.Body.Close() 23 | 24 | if resp.StatusCode != http.StatusOK { 25 | w.WriteHeader(http.StatusInternalServerError) 26 | return 27 | } 28 | 29 | if _, err := io.Copy(w, resp.Body); err != nil { 30 | fmt.Println("Something unrecoverable went wrong") 31 | return 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "os" 7 | 8 | "github.com/github/testdatabot/handlers" 9 | ) 10 | 11 | func main() { 12 | if err := run(); err != nil { 13 | fmt.Println(err) 14 | os.Exit(1) 15 | } 16 | } 17 | 18 | func run() error { 19 | http.HandleFunc("/random-commit-message", handlers.CommitMessage) 20 | http.HandleFunc("/random-lorem-ipsum", handlers.Loripsum) 21 | http.HandleFunc("/random-user", handlers.User) 22 | http.HandleFunc("/_ping", func(w http.ResponseWriter, r *http.Request) { 23 | w.Write([]byte("OK")) 24 | }) 25 | 26 | http.ListenAndServe(":8080", nil) 27 | return nil 28 | } 29 | --------------------------------------------------------------------------------