From 830200f7dcf8518fcafab930ceeafc7c364d3497 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Mon, 21 Oct 2024 13:20:27 -0700 Subject: [PATCH 1/9] Docs working branch for the SG v5.9 release --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f505ed9ef..f352a92d9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Sourcegraph Docs - + Welcome to the Sourcegraph documentation! We're excited to have you contribute to our docs. We've recently rearchitectured our docs tech stack — powered by Next.js, TailwindCSS and deployed on Vercel. This guide will walk you through the process of contributing to our documentation using the new tech stack. From d827e338cd4ed1a30e813cd80914bf9bd08a0b01 Mon Sep 17 00:00:00 2001 From: Petri-Johan Last Date: Tue, 22 Oct 2024 08:53:29 +0200 Subject: [PATCH 2/9] Add docs for Perforce IP enforcement (#691) --- docs/admin/repo/perforce.mdx | 68 +++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/docs/admin/repo/perforce.mdx b/docs/admin/repo/perforce.mdx index eee953679..f20e8811c 100644 --- a/docs/admin/repo/perforce.mdx +++ b/docs/admin/repo/perforce.mdx @@ -60,7 +60,7 @@ Sourcegraph will now talk to the Perforce host and sync the configured `depots` It's worthwhile to note some limitations of this process: -- When syncing depots either [git p4](https://git-scm.com/docs/git-p4) or [p4-fusion](https://github.com/salesforce/p4-fusion) (recommended) are used to convert Perforce depots into git repositories so that Sourcegraph can index them. +- When syncing depots [p4-fusion](https://github.com/salesforce/p4-fusion) is used to convert Perforce depots into git repositories so that Sourcegraph can index them. - Rename of a Perforce depot, including changing the depot on the Perforce server or the `repositoryPathPattern` config option, will cause a re-import of the depot. - Unless [permissions syncing](#repository-permissions) is enabled, Sourcegraph is not aware of the depot permissions, so it can't enforce access restrictions. @@ -126,11 +126,11 @@ If file-level permissions is not enabled, Sourcegraph provides limited support f ### File-level permissions -File-level permissions make the [syncing of subdirectories to match permission boundaries](#syncing-subdirectories-to-match-permission-boundaries) unnecessary. +File-level permissions eliminate the need for [syncing subdirectories to match permission boundaries](#syncing-subdirectories-to-match-permission-boundaries). To enable file-level permissions: -1. Enable [the feature in the site config](https://sourcegraph.com/github.com/sourcegraph/sourcegraph@2a716bd/-/blob/schema/site.schema.json?L227-249): +1. Add the following entry to your [site configuration file](https://sourcegraph.com/github.com/sourcegraph/sourcegraph@2a716bd/-/blob/schema/site.schema.json?L227-249): ```json { @@ -150,27 +150,70 @@ To enable file-level permissions: } ``` -1. Save the configuration. Permissions will be synced in the background based on your [Perforce protects file](https://www.perforce.com/manuals/cmdref/Content/CmdRef/p4_protect.html). +1. Save the configuration. -#### Handling Host rules in the protects file +Permissions will be synced in the background based on your [Perforce protects file](https://www.perforce.com/manuals/cmdref/Content/CmdRef/p4_protect.html). -When file-level permissions are enabled, Sourcegraph will read the Perforce protects file to determine what users can access. Because Sourcegraph originates all depot access from one host, protects rules with a Host field cannot be followed exactly. By default, they are parsed as if they apply to all hosts, which can result in users losing access when they should have access. If you have protects rules with hosts that are causing lost access for users, you can set `ignoreRulesWithHost` to `true` in the code host configuration. +#### Handling IP-based rules + +Perforce's `protects` table allows administrators to define fine-grained access controls based on user identities and host IP addresses. By default, Sourcegraph applies all rules from the `protects` table without considering host-specific restrictions, effectively treating all host rules as the wildcard `*`. This behavior can lead to users having unintended access to repositories or files that should be restricted based on their IP addresses. + +If your Perforce environment relies heavily on host-based permissions, it's crucial to configure Sourcegraph appropriately to respect these restrictions. This documentation provides detailed instructions on how to enforce or ignore host rules in Sourcegraph when integrating with Perforce. + +##### Default Behavior + +By default, Sourcegraph: + +- **Applies all rules** in the Perforce `protects` table. +- **Ignores host-specific restrictions**, treating all host fields as `*`. + +**Implication**: Users may gain access to resources that should be restricted based on their IP addresses. + +##### Configuration Options + +To ensure Sourcegraph handles host rules according to your requirements, you have two additional options: + +1. **Enforce Host Rules**: Configure Sourcegraph to respect and enforce IP-based restrictions defined in the `protects` table. +2. **Ignore Host-Specific Rules**: Configure Sourcegraph to disregard any rules with a host value other than `*`. + +##### Enforcing host rules + +If you want Sourcegraph to enforce host-specific permissions, you need to enable IP restriction enforcement in your [site configuration](https://sourcegraph.com/docs/admin/config/site_config): ```json - { - "authorization": { - "subRepoPermissions": true, - "ignoreRulesWithHost": true - } +{ + "experimentalFeatures": { + "subRepoPermissions": { + "enabled": true, + "enforceIPRestrictions": true } + } +} ``` + +When `enforceIPRestrictions` is set to `true`, Sourcegraph will use the user's IP address to apply Perforce permissions at the user level. It uses the final `X-Forwarded-For` header in the request to identify the user's IP. Note that this header can be easily spoofed, so ensure your load balancer or proxy handles `X-Forwarded-For` headers securely. + + +##### Ignore rules with host + +To ignore rules that have a host value other than `*`, set `ignoreRulesWithHost` to `true` in your **code host configuration**: + +```json +{ + "authorization": { + "subRepoPermissions": true, + "ignoreRulesWithHost": true + } +} +``` + +With this setting, Sourcegraph will ignore any rules with a host other than `*`, treating them as if they do not exist. ### Notes about permissions - Sourcegraph users are mapped to Perforce users based on their verified email addresses. - As long as a user has been granted at least `Read` permissions in Perforce they will be able to view content in Sourcegraph. - As a special case, commits in which a user does not have permissions to read any files are hidden. If a user can read a subset of files in a commit, only those files are shown. -- [The host field from protections are not supported](#known-issues-and-limitations). - [file-level permissions must be disabled for Batch Changes to work](#known-issues-and-limitations). - Setting `authz.enforceForSiteAdmins` to `true` in the site configuration will enforce permissions for admin users. They may not be able to see repositories and their contents if their Sourcegraph user account email does not match with their email on the Perforce server. @@ -228,7 +271,6 @@ When file-level permissions are enabled, Sourcegraph will read the Perforce prot We are actively working to significantly improve Sourcegraph's Perforce support. Please [file an issue](https://github.com/sourcegraph/sourcegraph/issues) to help us prioritize any specific improvements you'd like to see. - Sourcegraph was initially built for Git repositories only, so it stores Perforce depots as Git repositories when syncing. Perforce concepts and languages are expressed in the UI, but under the hood, Git tools are used. -- The [host field](https://www.perforce.com/manuals/cmdref/Content/CmdRef/p4_protect.html#Form_Fields_..361) in protections is not supported. - Batch Changes does not support [file-level permissions](#file-level-permissions) (also known as sub-repo permissions) - Batch Changes does not handle the shelved changelist other than to query the Perforce server for its status. - Permalinks with Changelist Id do not work yet From 991b79e5566d50e7b2f9b22b80bfd2480749254d Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 29 Oct 2024 13:26:19 -0700 Subject: [PATCH 3/9] Update versions --- docs.config.js | 2 +- docs/legacy.mdx | 1 + src/data/versions.ts | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs.config.js b/docs.config.js index ec0b4301b..3c0575d39 100644 --- a/docs.config.js +++ b/docs.config.js @@ -1,5 +1,5 @@ const config = { - DOCS_LATEST_VERSION: '5.8' + DOCS_LATEST_VERSION: '5.9' }; module.exports = config; diff --git a/docs/legacy.mdx b/docs/legacy.mdx index 6cb69756c..0540a44fb 100644 --- a/docs/legacy.mdx +++ b/docs/legacy.mdx @@ -4,6 +4,7 @@ + - [5.8](https://5.8.sourcegraph.com/) - [5.7](https://5.7.sourcegraph.com/) - [5.6](https://5.6.sourcegraph.com/) - [5.5](https://5.5.sourcegraph.com/) diff --git a/src/data/versions.ts b/src/data/versions.ts index 8068294bd..8484fbbd3 100644 --- a/src/data/versions.ts +++ b/src/data/versions.ts @@ -15,8 +15,8 @@ export const versions: VersionI[] = [ url: '/', }, { - name: 'v5.7', - url: 'https://5.7.sourcegraph.com/' + name: 'v5.8', + url: 'https://5.8.sourcegraph.com/' }, ]; From c74d6f7b4c698655047f6959ec2a468d657344f2 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 29 Oct 2024 19:48:11 -0700 Subject: [PATCH 4/9] Add updates about new search experience --- docs/code-search/features.mdx | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/docs/code-search/features.mdx b/docs/code-search/features.mdx index 87f2f9d50..70b211ad0 100644 --- a/docs/code-search/features.mdx +++ b/docs/code-search/features.mdx @@ -86,27 +86,7 @@ src search --json --stream -- "/$re2_regex/" \ ## Search experience -There is a new search experience in Sourcegraph `v5.6.0` and more. It is currently in the Beta stage. - -Users on Sourcegraph instance `v5.6.0` can try out the new Code Search experience by toggling the **Enable** button under **Try a new, faster UX** drop-down in the top right corner of the Code Search page. - -For Sourcegraph Enterprise users, their site admins must enable the new search experience first. Admins can go to **Site admin > Feature flags** from your Enterprise Sourcegraph instance to do so. Here, you can find the following feature flags that you should configure as follows: - -- `web-next`: `false` -- `web-next-rollout`: `true` -- `web-next-toggle`: `true` - -This configuration will work as follows: - -- `web-next`: When this flag is set the user will get the new web app for any page that is available in the new web app -- `web-next-rollout`: When this flag is set the user will get the new web app for pages that have been explicitly marked as `rolled out` -- `web-next-toggle`: When enabled users see a toggle in the top navbar that allows them to enable/disable the new web app for themselves - -Which flags configuration admins should set depends on the following scenarios: - -- If an admin want’s to allow users to opt-in to the new experience, then you should enable `web-next-toggle` for everyone -- If you want to enable the new web app for everyone you should set `web-next-rollout` -- If you want to allow people to opt-out they should additionally set `web-next-toggle` +Users on Sourcegraph instance `v5.9.0` or more get the improved and new Code Search experience set by default. Sourcegraph Enterprise users' site admins can optionally opt-out and revert to the old view. You get the following improvements: From 86cb5deebc2465c612408aeff08df29a985adebf Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 29 Oct 2024 20:04:09 -0700 Subject: [PATCH 5/9] upload video --- docs/cody/index.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/cody/index.mdx b/docs/cody/index.mdx index fe7fcdb26..34c3c6bab 100644 --- a/docs/cody/index.mdx +++ b/docs/cody/index.mdx @@ -1,9 +1,9 @@ # Cody -Cody is an AI coding assistant that helps you understand, write, and fix code faster. It uses advanced search to pull context from both local and remote codebases so that you can use context about APIs, symbols, and usage patterns from across your entire codebase. +Cody is an AI coding assistant that uses all the latest LLMs and your development context to help you understand, write, and fix code faster. It uses the powerful Sourcegraph Sourcegraph's advanced Search API to pull context from both local and remote codebases so that you can use context about APIs, symbols, and usage patterns from across your entire codebase. Cody connects seamlessly with codehosts like GitHub, GitLab and IDEs like VS Code and JetBrains. Once connected, Cody acts as your personal AI coding assistant, equipped with the following three crucial elements: From 277aa5b7e805ba30ce5700fbdda87a75969e9e09 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 29 Oct 2024 20:28:01 -0700 Subject: [PATCH 6/9] Update images in vscode --- docs/cody/clients/install-vscode.mdx | 22 +++++----------------- docs/cody/quickstart.mdx | 11 ++--------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/docs/cody/clients/install-vscode.mdx b/docs/cody/clients/install-vscode.mdx index e2c617a55..cc8d224cd 100644 --- a/docs/cody/clients/install-vscode.mdx +++ b/docs/cody/clients/install-vscode.mdx @@ -94,8 +94,6 @@ You should now be prompted to authorize Sourcegraph to connect to your VSCode ex Once connected, click the Cody icon from the sidebar again. The Cody extension will open in a configurable side panel. -![Cody icon in side activity bar ](https://storage.googleapis.com/sourcegraph-assets/Docs/cody-sidebar-0724.jpg) - Let's create an autocomplete suggestion to verify that the Cody extension has been successfully installed and is working as expected. Cody provides intelligent code suggestions and context-aware autocompletions for numerous programming languages like JavaScript, Python, TypeScript, Go, etc. @@ -129,7 +127,7 @@ The chat interface is designed intuitively. Your very first chat input lives at Since your first message to Cody anchors the conversation, you can return to the top chat box anytime, edit your prompt, or re-run it using a different LLM model. ### Chat History @@ -172,7 +170,7 @@ Cody defaults to showing @-mention context chips for all the context it intends When you start a new Cody chat, the chat input window opens with a default `@-mention` context chips for all the context it intends to use. This context is based on your current repository and current file (or a file selection if you have code highlighted). -![context-retrieval](https://storage.googleapis.com/sourcegraph-assets/Docs/context-retrieval-0724.jpg) +![context-retrieval](https://storage.googleapis.com/sourcegraph-assets/Docs/context-retrieval-102024.png) At any point in time, you can edit these context chips or remove them completely if you do not want to use these as context. Any chat without a context chip will instruct Cody to use no codebase context. However, you can always provide an alternate `@-mention` file or symbols to let Cody use it as a new source of context. @@ -211,10 +209,6 @@ If Cody's answer isn't helpful, you can try asking again with different context: - Current file only: Re-run the prompt again using just the current file as context. - Add context: Provides @-mention context options to improve the response by explicitly including files, symbols, remote repositories, or even web pages (by URL). - - ## Context fetching mechanism VS Code users on the Free or Pro plan use [local context](/cody/core-concepts/context#context-selection). @@ -247,14 +241,10 @@ Cody offers quick, ready-to-use [prompts and commands](/cody/capabilities/comman - **Document Code**: Add code documentation - **Edit Code**: Edit code with instructions - **Explain Code**: Describe your code with more details -- **Find Code Smells**: Identify bad code practices and bugs - **Generate Unit Tests**: Write tests for your code -- **Custom Commands**: Helps you write and define your own commands - -Let's understand how the `Document Code` command generates code documentation for a function. ### Custom Commands @@ -277,9 +267,7 @@ Cody lets you dynamically insert code from chat into your files with **Smart App Smart Apply also supports the executing of commands in the terminal. When you ask Cody a question related to terminal commands, you can now execute the suggestion in your terminal by clicking the `Execute` button in the chat window. - +![smart-apply](https://storage.googleapis.com/sourcegraph-assets/Docs/smart-apply-102024.png) ## Keyboard shortcuts @@ -309,7 +297,7 @@ Claude Sonnet 3.5 is the default LLM model for inline edits and commands. If you Users on Cody **Free** and **Pro** can choose from a list of supported LLM models for Chat and Commands. -![LLM-models-for-cody-free](https://storage.googleapis.com/sourcegraph-assets/Docs/LLM-Select-Free.png) +![LLM-models-for-cody-free](https://storage.googleapis.com/sourcegraph-assets/Docs/llm-dropdown-options-102024.png) Enterprise users get Claude 3 (Opus and Sonnet) as the default LLM models without extra cost. Moreover, Enterprise users can use Claude 3.5 models through Cody Gateway, Anthropic BYOK, AWS Bedrock (limited availability), and GCP Vertex. diff --git a/docs/cody/quickstart.mdx b/docs/cody/quickstart.mdx index 42921b47b..534982fd4 100644 --- a/docs/cody/quickstart.mdx +++ b/docs/cody/quickstart.mdx @@ -16,14 +16,11 @@ After installing the extension, the side activity bar will display an icon for **Cody**. Click this icon, and Cody's panel will open. This interface is used to start a **New Chat**, run Cody **commands**, prompts or get access to relevant resources. -![Cody icon in side activity bar ](https://storage.googleapis.com/sourcegraph-assets/Docs/cody-sidebar-0724.jpg) +![Cody icon in side activity bar ](https://storage.googleapis.com/sourcegraph-assets/Docs/cody-sidebar-102024.png) Cody supports **Prompts** and **Commands** with VS Code. These are quick, ready-to-use actions that you can apply to any code or text-based snippet you've highlighted. You can run a command in the following ways: -- Highlight your code and select the command or any prompt from the drop-down - -![running-commands](https://storage.googleapis.com/sourcegraph-assets/Docs/using-commands-0724.jpg) - +- Highlight your code and select the command or any prompt from the sidebar - Press `Option+K` to run an edit command exclusively - Right-click on any code element and select **Cody > Choose a command** from the list @@ -130,10 +127,6 @@ Leveraging the failed test output, Cody is able to identify the potential bug an Cody can also create well-crafted code documentation and comments, significantly improving the readability experience. You can add it by selecting a code snippet and running the **Document** command. Cody will add a comment to the top of the code snippet. - - ## Try other commands and Cody chat That's it for this quickstart guide! Feel free to continue chatting with Cody to learn more about its [capabilities](/cody/capabilities). Cody can run some other useful commands including: From 27287e628f07efe9f3b11109fba271a8c9f9b3f4 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 29 Oct 2024 20:36:28 -0700 Subject: [PATCH 7/9] Update images in jetbrains --- docs/cody/clients/install-jetbrains.mdx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/cody/clients/install-jetbrains.mdx b/docs/cody/clients/install-jetbrains.mdx index af4c0f539..79a8e73df 100644 --- a/docs/cody/clients/install-jetbrains.mdx +++ b/docs/cody/clients/install-jetbrains.mdx @@ -85,9 +85,7 @@ The chat interface is designed intuitively. Your very first chat input lives at Since your first message to Cody anchors the conversation, you can return to the top chat box anytime, edit your prompt, or re-run it using a different LLM model. - +![chat-interface](https://storage.googleapis.com/sourcegraph-assets/Docs/jb-chat-interface-102024.png) Users should be on the Cody for JetBrains extension v2023.2 or more to get this new and improved chat UI. @@ -138,7 +136,7 @@ For chat messages where Cody provides multiple code suggestions, you can apply e When you start a new Cody chat, the chat input window opens with a default `@-mention` context chips for all the context it intends to use. This context is based on your current repository and current file (or a file selection if you have code highlighted). -![jb-context-retrieval](https://storage.googleapis.com/sourcegraph-assets/Docs/jb-context-retrieval-0824.jpg) +![jb-context-retrieval](https://storage.googleapis.com/sourcegraph-assets/Docs/jb-context-retrieval-102024.png) At any point in time, you can edit these context chips or remove them completely if you do not want to use these as context. Any chat without a context chip will instruct Cody to use no codebase context. However, you can always provide an alternate `@-mention` file to let Cody use it as a new source of context. @@ -210,7 +208,7 @@ Cody with JetBrains offers quick, ready-to-use [prompts and commands](/cody/capa - **Smell Code**: Finds code smells in your file - **Explain Code**: Expains code in your file -![jetbrains-prompts-commands](https://storage.googleapis.com/sourcegraph-assets/Docs/jb-prompts-commands-0824.jpg) +![jetbrains-prompts-commands](https://storage.googleapis.com/sourcegraph-assets/Docs/jb-prompts-commands-102024.png) Let's learn about how to use some of these commands: From c64aae31da5d936a197cd8060bfc94140716d200 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Wed, 30 Oct 2024 15:25:27 -0700 Subject: [PATCH 8/9] Add docs for Visual Studio (#740) Docs for Visual Studio extension for Cody. --------- Co-authored-by: Kalan <51868853+kalanchan@users.noreply.github.com> --- docs/cody/clients/feature-reference.mdx | 49 +++++++------ docs/cody/clients/install-visual-studio.mdx | 77 +++++++++++++++++++++ docs/cody/index.mdx | 3 +- src/data/navigation.ts | 1 + 4 files changed, 104 insertions(+), 26 deletions(-) create mode 100644 docs/cody/clients/install-visual-studio.mdx diff --git a/docs/cody/clients/feature-reference.mdx b/docs/cody/clients/feature-reference.mdx index 84fb4c389..799c3c7d6 100644 --- a/docs/cody/clients/feature-reference.mdx +++ b/docs/cody/clients/feature-reference.mdx @@ -4,28 +4,27 @@ ## Chat -| **Feature** | **VS Code** | **JetBrains** | **Web** | **CLI** | -| ---------------------------------------- | ----------- | ------------- | -------------------- | ------- | -| Chat with Cody | ✅ | ✅ | ✅ | ✅ | -| Chat history | ✅ | ✅ | ✅ | ❌ | -| Clear chat history | ✅ | ✅ | ✅ | ❌ | -| Edit sent messages | ✅ | ❌ | ✅ | ❌ | -| Show context files | ✅ | ✅ | ✅ | ❌ | -| @-file | ✅ | ✅ | ✅ | ❌ | -| @-symbol | ✅ | ❌ | ✅ | ❌ | -| Ollama support (experimental) | ✅ | ✅ | ❌ | ❌ | -| LLM Selection | ✅ | ✅ | ✅ | ❌ | -| **Context Selection** | | | | | -| Single-repo context | ✅ | ✅ | ✅ | ❌ | -| Multi-repo context | ❌ | ❌ | ✅ (public code only) | ❌ | -| Local context | ✅ | ✅ | ❌ | ✅ | -| OpenCtx context providers (experimental) | ✅ | ❌ | ❌ | ❌ | -| **Prompts and Commands** | | | | -| Access to prompts and Prompt library | ✅ | ✅ | ✅ | ❌ | -| Custom commands | ✅ | ❌ | ❌ | ❌ | -| Edit code | ✅ | ✅ | ❌ | ❌ | -| Generate unit test | ✅ | ✅ | ❌ | ❌ | -| Ask Cody to Fix | ✅ | ✅ | ❌ | ❌ | +| **Feature** | **VS Code** | **JetBrains** | **Web** | **Visual Studio** | **CLI** | +| ---------------------------------------- | ----------- | ------------- | -------------------- | ----------------- | ------- | +| Chat with Cody | ✅ | ✅ | ✅ | ✅ | ✅ | +| Chat history | ✅ | ✅ | ✅ | ✅ | ❌ | +| Clear chat history | ✅ | ✅ | ✅ | ✅ | ❌ | +| Edit sent messages | ✅ | ❌ | ✅ | ✅ | ❌ | +| Show context files | ✅ | ✅ | ✅ | ✅ | ❌ | +| @-file | ✅ | ✅ | ✅ | ✅ | ❌ | +| @-symbol | ✅ | ❌ | ✅ | ✅ | ❌ | +| Ollama support (experimental) | ✅ | ✅ | ❌ | ✅ | ❌ | +| LLM Selection | ✅ | ✅ | ✅ | ✅ | ❌ | +| **Context Selection** | | | | | | +| Single-repo context | ✅ | ✅ | ✅ | ✅ | ❌ | +| Multi-repo context | ❌ | ❌ | ✅ (public code only) | ❌ | ❌ | +| Local context | ✅ | ✅ | ❌ | ✅ | ✅ | +| OpenCtx context providers (experimental) | ✅ | ❌ | ❌ | ❌ | ❌ | +| **Prompts and Commands** | | | | | | +| Access to prompts and Prompt library | ✅ | ✅ | ✅ | ✅ | ❌ | +| Edit code | ✅ | ✅ | ❌ | ❌ | ❌ | +| Generate unit test | ✅ | ✅ | ❌ | ❌ | ❌ | +| Ask Cody to Fix | ✅ | ✅ | ❌ | ❌ | ❌ | ## Code Autocomplete @@ -46,10 +45,10 @@ Few exceptions that apply to Cody Pro and Cody Enterprise users: -- Admin LLM selection is suported on VS Code, JetBrains, and Web both for chat and code autocomplete -- Multi-repo context is supported on VS Code, JetBrains, and Web +- Admin LLM selection is suported on VS Code, JetBrains, Visual Studio, and Web both for chat and code autocomplete +- Multi-repo context is supported on VS Code, JetBrains, Visual Studio, and Web - [Guardrails](/cody/clients/enable-cody-enterprise#guardrails) are supported on VS Code, JetBrains, and Web - [Repo-based Cody Context Filters](/cody/capabilities/ignore-context#cody-context-filters) are supported on VS Code, JetBrains, and Web -- `@-mention` directories are supported on VS Code, JetBrains, and Web +- `@-mention` directories are supported on VS Code, JetBrains, Visual Studio, and Web diff --git a/docs/cody/clients/install-visual-studio.mdx b/docs/cody/clients/install-visual-studio.mdx new file mode 100644 index 000000000..b18d89235 --- /dev/null +++ b/docs/cody/clients/install-visual-studio.mdx @@ -0,0 +1,77 @@ +# Installing Cody in Visual Studio + +

Learn how to use Cody and its features with the Visual Studio editor.

+ +Cody for Visual Studio is currently in the Experimental stage and currently only supports chat. + +Cody extension for Visual Studio enhances your coding experience by providing intelligent and contextually aware answers to your questions. This guide will walk you through installing and setting Cody within your Visual Studio editor. + + + + + +## Prerequisites + +- You have the latest version of [Visual Studio](https://visualstudio.microsoft.com/) installed +- You have a Free or Pro account via Sourcegraph.com or a Sourcegraph Enterprise account + +## Install the Visual Studio extension + +- Download the Cody extension for Visual Studio from the [GitHub repository](https://github.com/sourcegraph/cody-vs/releases) +- Run the installer and follow the prompts to install the extension +- Once installed, go to the **Extensions > Manage Extensions** tab in Visual Studio and search for Cody under the **Installed** list for confirmation + +## Connect the extension to Sourcegraph + +Cody for Visual Studio is available for all Cody plans, including Cody Free, Pro, and Enterprise. + +After a successful installation, go to **Tools** from the main toolbar at the top and click the **Cody Chat** from the drop-down. This opens the dialog box to connect to your Sourcegraph instance. + +Cody Free or Pro users can sign in to their Sourcegraph.com accounts through GitHub, GitLab, or Google. Meanwhile, Sourcegraph Enterprise users should connect Cody via their Enterprise instance URL and the Access Token. + +Complete these steps, and you'll be ready to start using Cody in Visual Studio. + +![install-cody-vscode](https://storage.googleapis.com/sourcegraph-assets/Docs/cody-vs-setup-102024-2.png) + +## Chat + +Cody in Visual Studio allows you to ask questions about your code and get contextually aware answers. The chat window is available in a unified interface next to your code. All your previous and existing chats are stored for later use and can be accessed via the **History** icon from the top menu. You can download them to share or use later in a `.json` file or delete them. + +The chat input field has a default `@-mention` [context chips](#context-retrieval). These are automatically populated with the names of the files you have open in your editor. There is also a drop-down for [LLM selection](#llm-selection) and a button to run pre-built [prompts and commands](#prompts). + +![cody-vs-chat](https://storage.googleapis.com/sourcegraph-assets/Docs/cody-visual-studio-1024.png) + +## LLM selection + +Cody offers a variety of large language models (LLMs) to power your chat experience. Cody Pro users can select the LLM they want to use for chat and experiment to choose the best model for the job. Choose from Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Sonnet, Claude 3 Haiku, GPT-4o, GPT-4 Turbo, GPT-3.5 Turbo, Google Gemini 1.5 Pro, Gemini 1.5 Flash, and Mixtral, while Cody Free users have access to the latest base models from Anthropic, OpenAI, Google, and Mixtral. + +Local models are also available through Ollama to Cody Free and Cody Pro users. To use a model in Cody chat, simply download it and run it in Ollama. + +Administrators for Sourcegraph Enterprise instances can also choose between Claude and GPT models to set for their teams. + +## Selecting Context with @-mentions + +Cody's chat allows you to add files and symbols as context in your messages. + +- Type `@-file` and then a filename to include a file as a context +- Type `@#` and then a symbol name to include the symbol's definition as context. Functions, methods, classes, types, etc., are all symbols + +![cody-vs-context-retrieval](https://storage.googleapis.com/sourcegraph-assets/Docs/cody-vs-mention-102024-2.png) + +### Context retrieval + +When you start a new Cody chat, the chat input window opens with a default `@-mention` context chips for all the context it intends to use. This context is based on your current repository and current file (or a file selection if you have code highlighted). + +At any point in time, you can edit these context chips or remove them completely if you do not want to use these as context. Any chat without a context chip will instruct Cody to use no codebase context. However, you can always provide an alternate `@-mention` file or symbols to let Cody use it as a new context source. + +When you have both a repository and files @-mentioned, Cody will search the repository for context while prioritizing the mentioned files. + +## Prompts + +Cody offers a variety of pre-built prompts and commands to help you get the most out of your chat experience. You can access these prompts and commands from the chat input field. Using one of these, you can ask Cody to: + +- Edit your code +- Document your code +- Generate unit tests + +![cody-vs-prompts](https://storage.googleapis.com/sourcegraph-assets/Docs/cody-vs-prompts-102024-2.png) diff --git a/docs/cody/index.mdx b/docs/cody/index.mdx index 34c3c6bab..3b805f88d 100644 --- a/docs/cody/index.mdx +++ b/docs/cody/index.mdx @@ -17,8 +17,9 @@ Cody connects seamlessly with codehosts like + + diff --git a/src/data/navigation.ts b/src/data/navigation.ts index 0a70c1909..56d86bf1c 100644 --- a/src/data/navigation.ts +++ b/src/data/navigation.ts @@ -36,6 +36,7 @@ export const navigation: NavigationItem[] = [ subsections: [ { title: "Cody for VS Code", href: "/cody/clients/install-vscode", }, { title: "Cody for JetBrains", href: "/cody/clients/install-jetbrains", }, + { title: "Cody for Visual Studio", href: "/cody/clients/install-visual-studio", }, { title: "Cody for Web", href: "/cody/clients/cody-with-sourcegraph", }, { title: "Cody for Enterprise", href: "/cody/clients/enable-cody-enterprise", }, { title: "Model Configuration", href: "/cody/clients/model-configuration", }, From ff9a3d124b5338331d2d88f1c68d5d3ba6dd6e51 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Thu, 31 Oct 2024 13:24:05 -0700 Subject: [PATCH 9/9] Add promoted Prompts --- docs/cody/capabilities/commands.mdx | 12 ++++++++++++ docs/cody/clients/feature-reference.mdx | 1 + 2 files changed, 13 insertions(+) diff --git a/docs/cody/capabilities/commands.mdx b/docs/cody/capabilities/commands.mdx index de6890c1e..be0814030 100644 --- a/docs/cody/capabilities/commands.mdx +++ b/docs/cody/capabilities/commands.mdx @@ -45,6 +45,18 @@ Prompts work in the same way as commands. Inside Cody's chat window there is a d ![prompts-in-dropdown](https://storage.googleapis.com/sourcegraph-assets/Docs/using-prompts.png) +## Promoted Prompts + +Promoted Prompts are supported in VS Code and Cody Web. + +Promoted Prompts allow admins to highlight Prompts to users at the top of a Prompt list in Cody chat, directing users to use specific Prompts that encourage best practices within the organization. Admins can promote a Prompt by checking the Promoted box in the Prompt edit screen. + +![promote-a-prompt](https://storage.googleapis.com/sourcegraph-assets/Docs/promote-promt-1024.png) + +Promoted Prompts are marked with an icon next to their name and appear at the top of the Prompt list in the Cody chat window in an IDE and the Prompt Library. + +![icon-promoted-prompts](https://storage.googleapis.com/sourcegraph-assets/Docs/promote-prompt-icon-1024.png) + ## Commands Cody offers quick, ready-to-use **commands** for common actions to write, describe, fix, and smell code. These allow you to run predefined actions with smart context-fetching anywhere in the editor. Like autocomplete and chat, commands will search for context in your codebase to provide more contextually aware and informed answers. diff --git a/docs/cody/clients/feature-reference.mdx b/docs/cody/clients/feature-reference.mdx index 799c3c7d6..ba5596f49 100644 --- a/docs/cody/clients/feature-reference.mdx +++ b/docs/cody/clients/feature-reference.mdx @@ -22,6 +22,7 @@ | OpenCtx context providers (experimental) | ✅ | ❌ | ❌ | ❌ | ❌ | | **Prompts and Commands** | | | | | | | Access to prompts and Prompt library | ✅ | ✅ | ✅ | ✅ | ❌ | +| Promoted Prompts | ✅ | ❌ | ✅ | ❌ | ❌ | | Edit code | ✅ | ✅ | ❌ | ❌ | ❌ | | Generate unit test | ✅ | ✅ | ❌ | ❌ | ❌ | | Ask Cody to Fix | ✅ | ✅ | ❌ | ❌ | ❌ |