please thoroughly read through the provided documentation below make sure you fully understand it in all the different configurations and options available I plan to have you edit my custom commands to improve them after you read the documentation but I want to make sure that you fully understand the documentation before I provide you with my cody.json commands that I want you to refractor to make them more efficient and well-defined and easier for an AI to understand in the next message I will provide you with my commands within my Cody.json for you to edit but please make sure that you've read and fully understand the documentation if you fully understand everything in this entire message just reply with yep I understand when you're ready to provide me with the cody.json and I will get started ``` # Custom Commands Documentation Commands (alongside Custom Commands) allow you to easily create and run reusable prompts without needing to submit pull requests or bring up the Chat sidebar. With commands, you can define customized prompts using JSON files that can be invoked simply by typing a `/` in chat box, or using keyboard shortcuts `⇧⌘V`, without opening the chat sidebar. This improves upon Recipes, which were limited to the Recipes tab and required pull requests. As a result, **Recipes have been deprecated in favor of the more flexible command system.** Use one of the steps listed below to run a command: - Type `/` in the chat box and select the desired command from the pop-up list. ![image](https://github.com/sourcegraph/cody/assets/68532117/fd48a949-2b08-44c6-818c-e99b616fc165) - Use `cmd+shift+v` anywhere in your document to open the Command Menu and select a command to run, without the chat sidebar. - Right-click on the selected code to open the Cody context menu and select a command. ![image](https://github.com/sourcegraph/cody/assets/68532117/989cd6f2-149b-424f-8eef-f221bca9cf46) - Search for `>Cody: Commands Menu` in your Command Palette to bring up the `Command Menu`. ![image](https://github.com/sourcegraph/cody/assets/68532117/3c1507dd-0fce-4e1c-b30d-d74256e43765) ## The cody.json File You can define custom commands for Cody in the `cody.json` file. To make commands accessible only in a specific project, create the cody.json file in the .vscode directory of your project. Cody will execute these workspace-specific custom commands when working in that project. To make commands accessible across multiple projects, create a new cody.json file in the .vscode directory of your home directory. Cody will execute these global custom commands in any workspace. ### Workspace vs. User Commands The location of cody.json determines the scope of your custom commands: - `cody.json` in a project's `.vscode` folder: Commands only available in that workspace - `cody.json` in home `.vscode` folder: Commands available globally across all workspaces This allows you to organize project-specific commands separately from reusable commands accessible globally. ### Structure The cody.json file allows customizable commands with prompts and contextual information to enhance Cody's abilities for your specific project needs. Below is the basic structure of the cody.json file: ```json { "commands": { "Command Name": { "prompt": "A set of questions with instructions for Cody to follow when answering questions.", "context": { "selection": "Include currently selected code from editor.", "openTabs": "Include code snippets from a list of open files in your current editor.", "currentDir": "Include code snippets from first n files in current directory.", "currentFile": "Include code snippets from current file.", "command": "Run terminal command locally and include output as context.", "none": "If true, overrides all other context settings." }, "slashCommand": "A single keyword for Cody to associate the command with during chat sessions, e.g. /reset", "note": "Optional additional note." } } } ``` The cody.json file allows customizable commands with prompts and contextual information to enhance Cody's abilities for your specific project needs. ### Fields - "commands": [REQUIRED] A list of custom commands - "Command Name": [REQUIRED] Unique name for Cody to identify each command. - "prompt": [REQUIRED] Text prompt sent to Cody when a command is executed. - "slashCommand": [OPTIONAL] Keyword you can use with "/" to invoke in chat. - "context": [OPTIONAL] Files/selection/tabs to share as context. - "selection": [OPTIONAL] Boolean to include currently selected code. When not specified, Cody will try to use visible content from the current file instead. - "openTabs": [OPTIONAL] Boolean to list open filenames/contents. - "currentDir": [OPTIONAL] Boolean to include snippets from first n directory files. - "currentFile": [OPTIONAL] Boolean to include snippets from the current file. If the file is too long, only the content surrounding the current selection will be included - "command": [OPTIONAL] Terminal command to run and include output. - "none": [OPTIONAL] Boolean that overrides other context settings if true. - "note": [OPTIONAL] Optional extra note about command. ## Command A command is a reusable set of prompts and context for specific use cases. Defining custom commands allows you to tailor Cody's actions in your workspace. - Commands allow customizable, reusable prompts tailored to specific use cases. - Define commands in the .vscode/cody.json file. - "Command Name" and "prompt" are required fields. - "context" and "note" are optional for providing extra context and details. Each command has: - "Command Name" (required): Displays in the Commands tab UI. - "prompt" (required): Instructions or questions sent to the language model when executing the command. - "context" (optional): Types of content (currentFile, selection, open tabs, current directory, etc) to provide additional context alongside the prompt. This gives Cody relevant references to aid in answering the prompt. - "note" (optional): Extra note about the purpose of this command. Basic Example 1: Current Directory Here is an example of what a basic command item looks like: ```json { "commands": { "Current Drectory Usage": { "prompt": "At a high level, explain what this directory is used for.", "context": { "currentDir": true } } } } ``` In this basic example: - The "Command Name" is "Explain This Directory". - The "prompt" asks Cody to explain the purpose of the current directory at a high level. - The "currentDir" context provides the files in the current directory as reference. Notes: - The "Command Name" and "prompt" fields are required. - "context" can enable things like "currentDir" to include relevant references. - This allows Cody to use the current directory files to explain the purpose of the directory when answering the prompt. Basic Example 2: Summarize Last Commit ```json { "commands": { "Summarize Last Commit": { "prompt": "Summarize the code changes from the latest commit from the output.", "context": { "command": "git --no-pager log", "selection": false } } } } ``` In this example: - The "prompt" instructs Cody to summarize the latest commit changes using the context. - The "command" context runs a git log command and includes the output. - "selection" is set to false since the current editor selection is not needed to summarize commit changes from the git log output. Notes: - Context like "command" can run external commands and include the output as reference for the prompt. - Irrelevant context like "selection" can be set to false to exclude it. - This allows tailoring the context to provide only what is needed for the prompt. ## Context The optional "context" field specifies what content Cody should reference when answering the command's "prompt". - Context allows including relevant references to aid the prompt. - Precise, limited context produces better results. - Many options are available like currentFile, selection, tabs, directories. - "none" overrides all other context if set to true. > NOTE: Providing limited but precise context helps Cody give more relevant responses. **By default, only the current editor selection is included.** Here are the context types available and their defaults: - "selection": undefined - Use currently selected text. When set to true, `selection` in the editor is required. When leaving it as `undefined`, Cody will try to use the currently visible content as context. Setting this to `false` will exclude any selection. - "openTabs": false - Use context from text documents in all currently open tabs. - "currentDir": false - Use files from the directory where the current file opened in the editor is located. - "currentFile": false - Use the current file opened in the editor. - "command": empty string - Use the output of this terminal command. e.g. git diff. See the `Context: Command` section for more information. - "none": false - Exclude all context. ### Context: Command The ability to provide command output as context gives Cody access to runtime information about your system. This enables more relevant, contextualized responses. Some examples include: - Build command output exposes errors/warnings in the latest build. Cody can then explain issues and suggest fixes. - Test command output reveals failing tests. Cody can suggest fixes or explain failures. - Dependency analysis output provides current package versions. Cody can recommend upgrades or explain compatibility. - System info like memory and disk usage allows Cody to recommend optimizations or explain performance issues. - Code quality tool output like linter warnings enables Cody to explain issues and recommend improvements. - Production logs and metrics help Cody debug errors or explain traffic spikes. Command output context gives Cody dynamic runtime data it normally couldn't access from static code alone. This provides a richer understanding of your live environment, enabling more relevant responses tailored to your system's specific state and issues. > Note: Ensure all the included command runs locally before configuring Cody to use its output as context. ## Slash Commands <img width="1018" alt="image" src="https://github.com/sourcegraph/cody/assets/68532117/45bd1d4b-a0b3-4eb3-9146-30be370847c5"> A slash command allows you to invoke a command from the chat box through the predefined word you set in the `slashCommand` field when you create a command. For example, setting the `slashCommand` field to `hello` creates a `/hello` command in the chat box, as seen in the image above. ```json { "commands": { "Hello World": { "prompt": "How to print hello world in Java?", "slashCommand": "hello" } } } ``` ## Instructions See the Quick Start section below. ## Quick Start > IMPORTANT: Custom Command is currently an experimental feature Follow the steps below to create a new User command: 1. Install and sign into the latest version of Cody in VS Code (v0.6.5). 2. Open a repository in your Editor --this will become your Workspace - IMPORTANT: [Multi-root Workspaces](https://code.visualstudio.com/docs/editor/multi-root-workspaces) is currently not supported by Cody 3. In Cody chat box, type `/` and press `ENTER` to submit. 4. In the quick pick menu, select `Configure Custom Commands...` <img width="1018" alt="Screenshot 2023-08-04 at 8 38 09 PM" src="https://github.com/sourcegraph/cody/assets/68532117/ad307dec-9e14-42e2-ad95-a51f69513a1d"> 5. Select `Open User Settings (JSON)` (this will automatically create a new `cody.json` file in your `$HOME/.vscode` directory if you don't have one already) <img width="1018" alt="Screenshot 2023-08-04 at 8 39 14 PM" src="https://github.com/sourcegraph/cody/assets/68532117/0d9ac2d7-e558-4557-a04a-7a8dfa608d98"> 6. In the `.vscody/cody.json` you just created/opened, you will see 2 examples provided for you. Try edit the prompt and save the file. For example, replace the `slashCommand` field with `hello` and the command's name and prompt with `hello world`: ```json { "commands": { "Hello World": { "prompt": "How to print hello world in Java?", "slashCommand": "hello" } } } ``` 7. After saving the file, type `/` in the chat box again or hit `cmd` + `shift` + `v` in your editor. 8. You should now see the `/hello` command you just added: <img width="1018" alt="image" src="https://github.com/sourcegraph/cody/assets/68532117/241452ea-b1b6-49b8-b7e4-fbb5d6a7b3ba"> <img width="1018" alt="image" src="https://github.com/sourcegraph/cody/assets/68532117/9a8a9c43-59c4-4f06-8519-b3cffaadb1b2"> 9. Typing `/hello` in the chat box and hitting enter will send the prompt `How to print hello world in Java?` to Cody: <img width="1018" alt="image" src="https://github.com/sourcegraph/cody/assets/68532117/5619ed46-8b52-460f-9fc7-0697e209d492"> ## Your First Custom Command In the tutorials below, you will build a new user command (a command that is available to you across workspaces) using the prompt from the old Smell Code recipe. ## Tutorial: Create a new custom command to "Make Code More Robust" #### Step 1: Copy the prompt below for `Make Code More Robust` Please review my selected code and provide a refactored version that improves readability, maintainability, performance, security, reduces redundancy, simplifies the logic, and overall quality without altering intended functionality. Focus only on rewriting the provided code - do not add new features or logic that is not already present. The goals are to produce a working code addressing issues in the mentioned areas while preserving existing behavior, reducing duplication, and simplifying where possible. Point out any significant changes you make and explain how they improve the code. If no major refactoring opportunities are identified, reply with 'No significant refactoring needed.' #### Step 2: Enter "/" in Cody Chat to bring up the command list, then click on the gear icon in the upper right <img width="1038" alt="Screenshot 2023-08-09 at 10 37 12 AM" src="https://user-images.githubusercontent.com/68532117/259498668-9da339d3-3c1a-47ca-b127-77d2420af940.png"> #### Step 3: Select `New Custom Command...` <img width="1038" alt="0_step_2" src="https://user-images.githubusercontent.com/68532117/259498349-8228006b-f14a-4cfe-9305-87cb168f0cb2.png"> #### Step 4: Follow the prompts to fill in the following: - slash name: robust - Description: Make Code More Robust <img width="1038" alt="0_step_3" src="https://user-images.githubusercontent.com/68532117/259498361-dbd3c2eb-862f-4819-bf8a-4c8ab03ea55d.png"> #### Step 5: Paste the prompt you copied from step 1 under "Prompt" <img width="1038" alt="0_step_4" src="https://user-images.githubusercontent.com/68532117/259498364-5acedcc7-a8ba-46ea-9b28-33f44fb065a0.png"> #### Step 6: Select `selected code` to use as context with the prompt <img width="1038" alt="0_step_5" src="https://user-images.githubusercontent.com/68532117/259498366-33f883d4-ce3f-4ed5-898c-3486442ef28b.png"> #### Step 7: That's it! When you bring up the `Command Menu` again (search for Command Menu in your command palette or use shortcut ⇧⌘V), you can find the `/robust` command you just added in the menu! <img width="1038" alt="image" src="https://user-images.githubusercontent.com/68532117/259501293-983df755-d26c-4765-bba0-eac91cb94c28.png"> ### Other ways to access the command menu Here are other ways to access the command menu... #### Cody Code Lenses Clicking on a code lens will automatically select the whole function and open the Command Menu for you: ![codelens_aug2023](https://github.com/sourcegraph/cody/assets/68532117/bad09d52-f1f1-4a24-8ebb-0c352d948adf) #### Editor Title Icon Click on the icon to open the Commands Menu to access your command list easily. ![editorIcon_aug2023](https://github.com/sourcegraph/cody/assets/68532117/df2751c4-504b-450c-a8e0-4c8998585000) ## Tutorial: cody.json for recreating Old Recipes Below are examples of commands created with the prompts used in the old recipes. #### Example cody.json ```json { "title": "[Example] From Recipes to Custom Commands", "commands": { "Explain Code in Detail": { "slashCommand": "old-explain-detailed", "prompt": "Please explain the selected {languageName} code. Be very detailed and specific, and indicate when it is not clear to you what is going on. Format your response as an ordered list.", "context": { "currentFile": true } }, "Generate a Unit Test": { "slashCommand": "old-test", "prompt": "Generate a unit test in {languageName} for the selected code", "context": { "currentDir": true, "currentFile": true, "selection": true } }, "Improve Variable Name": { "prompt": "Improve the variable names in the selected code.", "context": { "selection": true, "currentFile": true }, "type": "user", "slashCommand": "old-variable" }, "Translate code to Python": { "prompt": "Translate the selected code into Python.", "slashCommand": "old-translate-py" }, "Summarize Recent Code Changes": { "context": { "selection": false, "command": "git diff" }, "prompt": "Review the code changes in the shared output and draft a properly formatted commit message that summarizes the updates.", "slashCommand": "old-diff" }, "Generate Release Notes": { "prompt": "Generate release notes since last tag by summarising the shared git output.", "context": { "selection": false, "command": "git log --since=$(git describe --tags --abbrev=0) --pretty='Commit author: %an%nCommit message: %s%nChange description:%b%n'" }, "slashCommand": "old-release-notes" } } } ``` ## More Command Examples #### A command to create a README.md file for the current directory ```json { "commands": { "Create a README.md for Directory": { "prompt": "Write a detailed README.md file to document the code located in the same directory as my current selection. Summarize what the code in this directory is meant to accomplish. Explain the key files, functions, classes, and features. Use Markdown formatting for headings, code blocks, lists, etc. to make the it organized and readable. Aim for a beginner-friendly explanation that gives a developer unfamiliar with the code a good starting point to understand it. Make sure to include: - Overview of directory purpose - Functionality explanations - Relevant diagrams or visuals if helpful. Write the README content clearly and concisely using complete sentences and paragraphs based on the shared context. Use proper spelling, grammar, and punctuation throughout. Surround your full README text with triple backticks so it renders properly as a code block. Do not make assumptions or fabricating additional details.", "context": { "currentDir": true, "selection": true }, "slashCommand": "readme" } } } ``` The above command defines a README.md generator for the current directory. - The prompt instructs Cody to write a detailed README file that documents the code in the current directory. It specifies what content to include, like an overview, explanations of functionality, diagrams, etc. - The context settings provide relevant information for Cody: - `currentDir: true`: shares files from the current directory as context. This gives Cody the code examples needed to summarize. - `selection: true`: include the currently selected text. This helps Cody to identify the specific directory you are referring to. - `slashCommand: readme`: this field enables invoking this command easily in chat by typing `/readme`. This command leverages context from the current directory and selection to generate a high-quality README file summarizing the code. The slashCommand field also makes it convenient to generate documentation for any directory right from chat. #### A command for debugging the latest error message from the Cody app log file ```json { "commands": { "Debug last error from Cody app": { "prompt": "Tell me about the most recent error in log and how I can resolve it.", "context": { "selection": false, "command": "tail -n 30 ~/Library/Logs/com.sourcegraph.cody/Cody.log" }, "note": "You must have Cody app installed to use this command" } } } ``` #### A command to compare file content from open tabs The following command leverages active editor tabs as a context source to have Cody compare and explain code relationships across potentially disparate samples. The `openTabs` context avoids assumptions of inter-relatedness that codebase search can make. ```json { "commands": { "Compare Files in Opened Tabs": { "prompt": "Please examine the shared code snippets from my opened tabs. Then explain the relationship between the code samples by answering these questions: 1. What are the main tasks or functions the code is performing? 2. Are there any similarities in functions or logic across the samples? 3. Does one code snippet call or import another? If so, how do they interact? 4. Are there any notable differences in how they approach similar problems? 5. Overall, how are the code snippets related - do they work together as part of a larger program, solve variants of the same problem, or serve entirely different purposes?", "context": { "openTabs": true, "selection": false } } } } ``` The above command compares code across open editor tabs. It prompts Cody to examine the tabs and explain the relationships between them by answering: - What are the main tasks/functions? - Any similarity in functions/logic? - Does one call or import another? - Notable differences in approaches? - Overall, how are they related? The context shares code snippets from files in the `openTabs`, which provides Cody with the code snippets for comparison. > NOTE: Using `openTabs` is useful when analyzing unrelated files in different directories #### Commands that analyze command output ```json { "commands": { "GH Search: Deployed Repositories not owned by Sourcegraph": { "prompt": "Find repositories used for deploying Sourcegraph but not directly owned by Sourcegraph.", "context": { "command": "gh search repos sourcegraph deploy", "selection": false }, "note": "Make sure you have the 'gh' command installed and authenticated. " } } } ``` The above command searches GitHub for repositories used to deploy Sourcegraph but not owned directly by Sourcegraph. - It defines a prompt asking Cody to find these external deployment repositories. - The context field runs the gh command to search GitHub, with the query "sourcegraph deploy". This outputs a list of matching repositories. - Sharing the gh search output gives Cody the context to summarize the results. - The note reminds users to have gh installed and authenticated for the command to work. - This command surfaces third-party repositories critical for Sourcegraph deployment by leveraging GitHub search via the gh CLI. The command output context gives Cody the data to summarize the results. > NOTE: Ensure you have the 'gh' command installed and authenticated. Here is another example for analyzing the terminal command output: ```json { "commands": { "Debug last error from Cody app": { "prompt": "Tell me about the most recent error in the log and how I can resolve it.", "context": { "selection": false, "command": "tail -n 30 ~/Library/Logs/com.sourcegraph.cody/Cody.log" }, "note": "You must have Cody app installed to use this command." } } } ``` #### A command for suggesting a meaningful commit message for the current change ```json { "commands": { "Commit Message for Current Changes": { "prompt": "Suggest an informative commit message by summarizing code changes from the shared command output. The commit message should follow the conventional commit format and provide meaningful context for future readers.", "context": { "selection": false, "command": "git diff" }, "note": "You must have git installed and authenticated to use this command." } } } ``` This defines a command to generate a commit message: - The prompt asks Cody to summarize the git diff and suggest a commit message. - The context runs git diff to share the code changes since the last commit. - Cody should analyze the diff output and write a commit message summarizing the changes. - The message should use the conventional commit format for consistency. - The info note reminds users to have git installed and set up. This allows users to generate meaningful commit messages from current code changes quickly. Sharing the git diff output provides context for Cody to summarize. #### A command for summarizing web content retrieved with a curl command ```json { "commands": { "Summarize the latest Cody Release": { "prompt": "What is the latest stable version of Cody? Can you briefly summarize the changes that were included in that release based on this CHANGELOG excerpt?", "context": { "selection": false, "command": "curl https://raw.githubusercontent.com/sourcegraph/cody/main/vscode/CHANGELOG.md | head -n 50" } } } } ``` This defines a command to summarize a new Cody release: - The prompt asks Cody to identify the latest version and summarize the changes. - The context curl's the Cody changelog and shares the latest release section. - Cody should parse the changelog excerpt to identify the new version and summarize the changes. - This quickly surfaces key improvements in the latest Cody release by leveraging the changelog. - The curl command retrieves the relevant part of the changelog to provide context. This allows users to get a summary of a new software release by providing the changelog content for Cody to analyze. ## Tutorial: Use bash script output as context You can provide Cody with output from your terminal. In this tutorial, we will walk through how to create a custom command for Cody to explain the output of a Bash script located outside your current workspace. ### 1. First, create a Bash script. We will use the following script that prints "Hello World" as an example: ``` #!/bin/bash echo "Hello World" ``` ### 2. Save the file to a directory outside your current workspace, and get the file's absolute path. ### 3, In your Custom Command config file cody.json, add the following command called "bash": ``` "bash": { "description": "Bash script to print hello world.", "prompt": "Summarize the output in one sentence.", "context": { "selection": false, "command": "bash /Users/USERNAME/SCRIPT_NAME.sh" } }, ``` > IMPORTANT: Replace "bash /Users/USERNAME/SCRIPT_NAME.sh" with the file's absolute path inside thebash.context.command field. ### 4. Run the new command with `/bash` in chat. Cody should explain the output of the script in one sentence. ![image](https://github.com/sourcegraph/cody/assets/68532117/85c726b6-cb25-4ff9-9e83-004a350dd322) ```
the purpose of this conversation is for you to drastically improve the capability and performance within my Cody AI custom commands keep in mind this codi.json contains multiple different prompts I only want you to edit the text within the prompt portion don't worry about anything else please remember only modify the "prompt" sections of the json code overall I like my current commands but they should be improved versions of what I already have implemented basic overview information for creating efficient and powerful commands for codi ai: ## How to Create Effective Prompts for Custom Commands Follow these guide lines to craft prompts that help Cody AI understand and assist you better: 1. **Be Specific:** Include details like programming language, frameworks, and the goal of your code. 2. **Provide Context:** Explain what the code should do and any project constraints. 3. **Use Clear Language:** Be direct and avoid ambiguity in your descriptions. 4. **Include Code Snippets:** Share relevant code, ensuring sensitive information is removed. 5. **Format Your Prompt:** Use markdown for code blocks and inline code for clarity. 6. **Ask One Thing at a Time:** Focus on a single issue or question to get targeted help. 7. **Provide Examples:** Show sample output or behaviour you're aiming for. 8. **Use Keywords:** Include relevant terms to help the AI identify main topics. 9. **Clarify the Help Needed:** Specify whether you need debugging, writing, optimizing, etc. now that you fully understand all the information about the custom commands and how they work I want you to edit my custom command json file remember don't remove anything you're only improving the prompt portions additionally if the prompt doesn't properly align with the context options for that prompt feel free to modify them to improve the prompts but like I said before focus on editing the prompt sections heres my codi AI custom commands- cody.json = [placeholder]
awesome now that you have modified the codi.json can you give a brief description of the changes you made and explain your reason for each and every change you made keep it short and sweet though