Skip to content

Commit 1f6aab0

Browse files
authored
Improve cody docs (#747)
Improve cody docs
1 parent 039504a commit 1f6aab0

File tree

4 files changed

+113
-65
lines changed

4 files changed

+113
-65
lines changed

docs/cody/capabilities/autocomplete.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ By default, a fully configured Sourcegraph instance picks a default LLM to gener
4141
- Click the **Save** button to save the changes
4242

4343
Cody supports and uses a set of models for autocomplete. Learn more about these [here](/cody/capabilities/supported-models#autocomplete). It's also recommended to read the [Enabling Cody on Sourcegraph Enterprise](/cody/clients/enable-cody-enterprise) docs.
44+
45+
## LLM models for autocomplete
46+
47+
Cody uses a set of models for autocomplete. Learn more about these [here](/cody/capabilities/supported-models#autocomplete).

docs/cody/capabilities/chat.mdx

Lines changed: 83 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,118 @@
22

33
<p className="subtitle">Use Cody's chat to get contextually-aware answers to your questions.</p>
44

5-
Cody **chat** allows you to ask coding-related questions about any part of your codebase or specific code snippets. You can do it from the **Chat** panel of the supported editor extensions (VS Code, JetBrains) or in the web app.
5+
You can **chat** with Cody to ask questions about your code, generate code, and edit code. By default, Cody has the context of your open file and entire repository, and you can use `@` to add context for specific files, symbols, remote repositories, or other non-code artifacts.
66

7-
Key functionalities in the VS Code extension include support for multiple simultaneous chats, enhanced chat context configurability through @-mentions, detailed visibility into the code that Cody read before providing a response, and more.
8-
9-
You can learn more about the IDE support for these functionalities in the [feature parity reference](/cody/clients/feature-reference#chat).
7+
You can do it from the **chat** panel of the supported editor extensions ([VS Code](/clients/install-vscode), [JetBrains](/clients/install-jetbrains), [Visual Studio](/clients/install-visual-studio)) or in the [web](/clients/cody-with-sourcegraph) app.
108

119
## Prerequisites
1210

13-
To use Cody's chat, you'll need to have the following:
11+
To use Cody's chat, you'll need the following:
1412

1513
- A Free or Pro account via Sourcegraph.com or a Sourcegraph Enterprise account
16-
- A supported editor extension (VS Code, JetBrains) installed
14+
- A supported editor extension (VS Code, JetBrains, Visual Studio) installed
1715

1816
## How does chat work?
1917

20-
Cody answers questions by searching your codebase and retrieving context relevant to your questions. Cody uses several methods to search for context, including Sourcegraph's native search and keyword search. Finding and using context allows Cody to make informed responses based on your code rather than being limited to general knowledge. When Cody retrieves context to answer a question, it will tell you which code files it read to generate its response.
18+
Cody answers questions by searching your codebase and retrieving context relevant to your questions. Cody uses several methods to search for context, including Sourcegraph's native search and keyword search. Finding and using context allows Cody to make informed responses based on your code rather than being limited to general knowledge. When Cody retrieves context to answer a question, it will tell you which code files it reads to generate its response.
2119

22-
Cody can assist you with various use cases such as:
20+
Cody can assist you with various use cases, such as:
2321

2422
- Generating an API call: Cody can analyze your API schema to provide context for the code it generates
2523
- Locating a specific component in your codebase: Cody can identify and describe the files where a particular component is defined
2624
- Handling questions that involve multiple files, like understanding data population in a React app: Cody can locate React component definitions, helping you understand how data is passed and where it originates
2725

28-
## Ask Cody your first question
26+
## Chat features
2927

30-
Let's use Cody VS Code extension's chat interface to answer your first question.
28+
There are several features that you can use to make your chat experience better. These features may vary depending on the [client](/cody/clients) you are using. You can learn more about the support for these functionalities in the [feature parity reference](/cody/clients/feature-reference#chat).
3129

32-
- Click the Cody icon in the sidebar to view the detailed panel
33-
- Next, click the icon for **New Chat** to open a new chat window
34-
- Write your question or instruction to Cody and then press **Enter**.
30+
## Default context
3531

36-
For example, ask Cody "What does this file do?"
32+
When you start a new Cody chat, the input window opens with a default `@-mention` context chips for the opened file and the current repository.
3733

38-
Cody will take a few seconds to process your question, providing contextual information about the files it reads and generating the answer.
34+
![context-retrieval](https://storage.googleapis.com/sourcegraph-assets/Docs/context-retrieval-102024.png)
3935

40-
<video width="1920" height="1080" loop playsInline controls style={{ width: '100%', height: 'auto', aspectRatio: '1920 / 1080' }}>
41-
<source src="https://storage.googleapis.com/sourcegraph-assets/Docs/Media/chat-interface-0724.mp4" type="video/mp4" />
42-
</video>
36+
At any point in time, you can edit these context chips or remove them entirely 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.
4337

44-
## Ask Cody to write code
38+
When you have both a repository and files @-mentioned, Cody will search the repository for context while prioritizing the mentioned files.
4539

46-
The chat feature can also write code for your questions. For example, in VS Code, ask Cody to "write a function that sorts an array in ascending order".
40+
## Add new context
4741

48-
You are provided with code suggestions in the chat window along with the following options for using the code.
42+
You can add new custom context by adding `@-mention` context chips to the chat. At any point, you can use `@-mention` a repository, file, line range, or symbol, to ask questions about your codebase. Cody will use this new context to generate contextually relevant code.
4943

50-
- The **Copy Code** icon to your clipboard and paste the code suggestion into your code editor
51-
- Insert the code suggestion at the current cursor location by the **Insert Code at Cursor** icon
52-
- The **Save Code to New File** icon to save the code suggestion to a new file in your project
44+
## OpenCtx context providers
45+
46+
<Callout type="info">OpenCtx context providers are in the Experimental stage for all Cody VS Code users. Enterprise users can also use this, but with limited support. If you have feedback or questions, please visit our [support forum](https://community.sourcegraph.com/c/openctx/10).</Callout>
47+
48+
[OpenCtx](https://openctx.org/) is an open standard for bringing contextual info about code into your dev tools. Cody Free and Pro users can use OpenCtx providers to fetch and use context from the following sources:
49+
50+
- [Webpages](https://openctx.org/docs/providers/web) (via URL)
51+
- [Jira tickets](https://openctx.org/docs/providers/jira)
52+
- [Linear issues](https://openctx.org/docs/providers/linear-issues)
53+
- [Notion pages](https://openctx.org/docs/providers/notion)
54+
- [Google Docs](https://openctx.org/docs/providers/google-docs)
55+
- [Sourcegraph code search](https://openctx.org/docs/providers/sourcegraph-search)
56+
57+
You can use `@-mention` web URLs to pull live information like docs. You can connect Cody to OpenCtx to `@-mention` non-code artifacts like Google Docs, Notion pages, Jira tickets, and Linear issues.
58+
59+
## Run offline
60+
61+
<Callout type="info">Support with Ollama is currently in the Experimental stage and is available for Cody Free and Pro plans.</Callout>
62+
63+
Cody chat can run offline with Ollama. The offline mode does not require you to sign in with your Sourcegraph account to use Ollama. Click the button below the Ollama logo, and you'll be ready to go.
64+
65+
![offline-cody-with-ollama](https://storage.googleapis.com/sourcegraph-assets/Docs/cody-offline-ollama.jpg)
66+
67+
You can still switch to your Sourcegraph account whenever you want to use Claude, OpenAI, Gemini, Mixtral, etc.
68+
69+
## LLM selection
70+
71+
Cody allows you to select the LLM you want to use for your chat, optimized for speed versus accuracy. Cody Free and Pro users can select multiple models. Enterprise users with the new [model configuration](/cody/clients/model-configuration) can use the LLM selection dropdown to choose a chat model.
5372

54-
During the chat, if Cody needs additional context, it can ask you to provide more information with a follow-up question. If your question is beyond the scope of the context, Cody will ask you to provide an alternate question aligned with the context of your codebase.
73+
You can read about these supported LLM models [here](/cody/capabilities/supported-models#chat-and-commands).
5574

56-
## Selecting Context
75+
![LLM-models-for-cody-free](https://storage.googleapis.com/sourcegraph-assets/Docs/llm-dropdown-options-102024.png)
5776

58-
Cody's chat allows you to add files and symbols as context in your messages.
77+
## Smart Apply and Execute code suggestions
5978

60-
- Type `@` and then a filename to include a file as context
61-
- Type `@#` and then a symbol name to include the symbol's definition as context. Functions, methods, classes, types, etc., are all symbols
79+
Cody lets you dynamically insert code from chat into your files with **Smart Apply**. Whenever Cody provides a code suggestion, you can click the **Apply** button. Cody will then analyze your open code file, find where that relevant code should live, and add a diff. For chat messages where Cody provides multiple code suggestions, you can apply each in sequence to go from chat suggestions to written code.
6280

63-
Cody's experimental [OpenCtx](/cody/capabilities/openctx) support adds even more context sources, including Jira, Linear, Google Docs, Notion, and more.
81+
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.
6482

65-
### Chat vs Commands
83+
![smart-apply](https://storage.googleapis.com/sourcegraph-assets/Docs/smart-apply-102024.png)
84+
85+
## Chat history
86+
87+
Cody keeps a history of your chat sessions. You can view it by clicking the **History** button in the chat panel. You can **Export** it to a JSON file for later use or click the **Delete all** button to clear the chat history.
88+
89+
## Prompts and Commands
90+
91+
Cody offers quick, ready-to-use [prompts and commands](/cody/capabilities/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:
92+
93+
- **New Chat**: Ask Cody a question
94+
- **Document Code**: Add code documentation
95+
- **Edit Code**: Edit code with instructions
96+
- **Explain Code**: Describe your code with more details
97+
- **Generate Unit Tests**: Write tests for your code
98+
99+
<video width="1920" height="1080" loop playsInline controls style={{ width: '100%', height: 'auto' }}>
100+
<source src="https://storage.googleapis.com/sourcegraph-assets/Docs/Media/cody-prompts-102024-2.mp4" type="video/mp4" />
101+
</video>
102+
103+
Read more about [prompts and commands](/cody/capabilities/commands).
104+
105+
## Ask Cody to write code
106+
107+
Cody chat can also write code for your questions. For example, in VS Code, ask Cody to "write a function that sorts an array in ascending order".
108+
109+
You are provided with code suggestions in the chat window and the following options for using the code.
110+
111+
- The **Copy Code** icon to your clipboard and paste the code suggestion into your code editor
112+
- Insert the code suggestion at the current cursor location by the **Insert Code at Cursor** icon
113+
- The **Save Code to New File** icon to save the code suggestion to a new file in your project
66114

67-
There could be scenarios when Cody's chat might not be able to answer your question. Or the answer lacks the context that you need. In these cases, it's recommended to use Cody **commands**. Cody's responses to commands might be better at times than responses to chats since they've been pre-packaged and prompt-engineered.
115+
If Cody's answer isn't helpful, you can try asking again with a different context:
68116

69-
<Callout type="note"> Commands are only supported in the VS Code and JetBrains extension.</Callout>
117+
- **Public knowledge only**: Cody will not use your own code files as context; it’ll only use knowledge trained into the base model.
118+
- **Current file only**: Re-run the prompt again using just the current file as context.
119+
- **Add context**: Provides @-mention context options to improve the response by explicitly including files, symbols, remote repositories, or even web pages (by URL).

docs/cody/capabilities/commands.mdx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,56 @@
11
# Prompts and Commands
22

3-
<p className="subtitle">Learn how prompts and commands can kick-start your workflow.</p>
3+
<p className="subtitle">Learn how prompts and commands can kick-start your workflow with Cody.</p>
44

55
## Prompts
66

77
<Callout type="note">Prompts and Prompts Library are currently available in Cody's VS Code extension and the Sourcegraph Web UI.</Callout>
88

9-
Apart from these ready-to-use commands, you can create your own prompts from the **Prompt Library** via the Sourcegraph's Web UI. From here, you can easily create, edit, share, and discover prompts you’ve created or have been shared within your organization.
9+
Cody offers quick, ready-to-use **Prompts** to automate key tasks in your workflow. Prompts are created and saved in the **Prompt Library** and can be accessed from the **Tools > Prompt Library** in the top navigation bar in Sourcegraph's web UI.
1010

11-
## Prompt Library
12-
13-
The Prompt Library can be accessed from the **Tools > Prompt Library** in the top navigation bar in Sourcegraph's web UI. From here, you can view, create or edit a prompt. You can also search for prompts, filter the list to find a specific prompt by owner, and sort by name or recently updated.
11+
From here, you can easily create, edit, share, and discover prompts you’ve created or have been shared within your organization. You can also search for prompts, filter the list to find a specific prompt by owner, and sort by name or recently updated.
1412

1513
![prompt-library-overview](https://storage.googleapis.com/sourcegraph-assets/Docs/prompt-library-overview-0824.png)
1614

1715
### Create and edit a prompt
1816

1917
Click the **New prompt** button on the **Prompt Library** page to create a new prompt.
2018

21-
- Select the **Owner** and **Name** of the prompt
22-
- Then, write a prompt description
23-
- And finally, fill out the **Prompt template** box with all your prompt instructions
24-
- Moreover, you can mark your prompt as **Draft**.
19+
- Select the **Owner** and **Prompt Name**
20+
- Next, write a prompt description
21+
- Finally, fill out the **Prompt template** box with all your prompt instructions
22+
- You can also add dynamic context that will allow your prompt to use content from different sources like current selection and current file
23+
- Select the visibility of the prompt, either **Public** or **Private**
2524
- Once done, click the **Create prompt** button
2625

26+
A few advanced options exist to create a prompt that you can configure. They are in the Advanced section.
27+
28+
![create-prompt](https://storage.googleapis.com/sourcegraph-assets/Docs/create-prompt-1124.png)
29+
2730
The prompt is visible to and usable by:
2831

29-
- The prompt's owner: if the prompt's owner is a user
30-
- All members of the organization: if the prompt's owner is an organization
31-
- Everyone: if the prompt is marked **Public** (which only site admins can do)
32+
- **The prompt's owner**: If the prompt's owner is a user
33+
- **All members of the organization**: If the prompt's owner is an organization
34+
- **Everyone**: If the prompt is marked **Public** (which only site admins can do)
3235

3336
Completing this process will do the following:
3437

3538
- The new prompt will be added to the **Prompt Library** page
36-
- The prompt will appear in the Prompts list in Cody (in the editor and on the web)
39+
- The prompt will appear in the Prompts list in the Cody chat panel (in the editor and on the web)
3740

3841
![prompts-in-vscode](https://storage.googleapis.com/sourcegraph-assets/Docs/prompts-ui-vscode-082024.png)
3942

4043
### Draft prompts
4144

42-
You can mark your prompt as a draft. A draft prompt cannot be seen by anyone but you. You can only see and modify your draft prompts via the **Prompt Library** via the Sourcegraph's Web UI.
45+
You can mark your prompt as a draft. A draft prompt is not visible to everyone. You can only see and modify your draft prompts via the **Prompt Library** via the Sourcegraph's Web UI.
4346

4447
### Editing a prompt
4548

4649
To edit a prompt, click the Edit button next to the prompt in the Prompt Library and make the necessary changes. You can also use this interface to **transfer ownership** of the prompt or delete it from this view.
4750

48-
4951
### Using prompts
5052

51-
Prompts work in the same way as commands. Inside Cody's chat window there is a drop-down called **prompts** next to the LLM selector. Use this to select a prompt and run on your codebase.
53+
Prompts work in the same way as commands. Inside Cody's chat window is a drop-down called **prompts** next to the LLM selector. Use this to select a prompt and run on your codebase.
5254

5355
![prompts-in-dropdown](https://storage.googleapis.com/sourcegraph-assets/Docs/using-prompts.png)
5456

@@ -66,6 +68,8 @@ Promoted Prompts are marked with an icon next to their name and appear at the to
6668

6769
## Commands
6870

71+
<Callout type="info"> Prompts' functionality largely overlaps with commands. We intend to sunset commands in an upcoming release in favor of Prompts and the Prompt Library.</Callout>
72+
6973
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.
7074

7175
Commands are available in VS Code, JetBrains, and the Sourcegraph web app. Commands can handle tasks like:

0 commit comments

Comments
 (0)