Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Commit 0e747ee

Browse files
authored
Merge pull request #1 from Granite-Code/first-content
Add initial batch of content
2 parents 41672cd + 2bc0e01 commit 0e747ee

File tree

9 files changed

+233
-29
lines changed

9 files changed

+233
-29
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# Granite.Code Docs
22

3-
Granite.code user documentation website. Content is written in Markdown. Static HTML site is generated using Sphinx.
3+
Granite.Code user documentation website. Content is written in Markdown. Static HTML site is generated using Sphinx.
44

5+
## Building
6+
7+
To build this site locally, run:
8+
9+
```
10+
sphinx-build -j auto -b html docs build
11+
```

docs/best-practices.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Best Practices
2+
3+
This page provides information on how to get the most out of Granite.Code. It covers best practices for getting accurate and helpful chat responses, as well as supplementary options which make Granite.Code's features even more powerful.
4+
5+
Before you read this guide, you should be familiar with the main Granite.Code features, which are described in the [getting started tutorial](FIXME).
6+
7+
## Asking effective questions
8+
9+
Being able to chat with a local AI model is one of the main features offered by Granite.Code. When asking questions or creating prompts for an AI model, there are a number of best practices which will help you to get the best responses possible:
10+
11+
* Always be as specific and precise as possible, and avoid broad or vague questions.
12+
* If you are asking a complex question, consider breaking it down into sections. Questions can include paragraphs and lists of information, which can be useful to keep them organized. This will make it easier for the model to interpret what you are asking.
13+
* If you want the model to provide an answer in a specific format, say what it is. For example, you could ask for a list of short points, or a code example, or you could ask for references for further reading.
14+
* If a question doesn't give you the answer you want, use follow-up questions to refine or amend it.
15+
16+
Remember that asking AI models questions is a skill that gets better with practice.
17+
18+
## Providing context for queries
19+
20+
Most questions have a context that they are related to. In the coding world that context can be a project, a file, a programming language, a platform, or code section. However, by default an AI model has no information about that context: its response will be based only on the prompt it receives and the general information that it already has access to.
21+
22+
This is where context comes in. Context allows you to feed additional information to the model, so that it has additional knowledge about the question you are asking. Granite.Code allows a variety of different types of context to be specified for a question. These include:
23+
24+
* `@Files`: adds specific files
25+
* `@Folder`: adds a specific folder
26+
* `@Codebase`: adds all the files in the current project
27+
* `@Terminal`: adds the contents of the VS Code terminal
28+
* `@Git Diff`: adds the Git changes in the current branch
29+
* `@Problems`: adds data from the VS Code problems panel
30+
31+
To use any of these types of context to a question, just type an **@** symbol in the chat, and a list of available context types will be shown. You can also click the **@** button in the chat prompt.
32+
33+
Some examples of questions you can ask that make use of additional context:
34+
35+
* Please summarize @sort.js
36+
* How do I fix the syntax errors in @sort.js @Problems
37+
* When I ran ``git pull`` I got weird errors. Please explain @Terminal
38+
* Please write a commit message for the current @Git Diff
39+
40+
## Using docs
41+
42+
`@Docs` is another powerful type of context in Granite.Code, which can be used to ask questions that have a documentation website as its context.
43+
44+
What makes `@Docs` a little different is that it must be set up prior to use. To do this:
45+
46+
1. Click the docs button above the chat prompt.
47+
2. Enter a title and URL for the docs site you want to make available.
48+
3. Click add, and wait for indexing to complete.
49+
50+
Once this has been done you can enter `@Docs` in the chat prompt to use a docs site in a question.
51+
52+
For more information on the docs context provider, see the [Continue documentation](https://docs.continue.dev/customize/deep-dives/docs).
53+
54+
## Making different types of edits
55+
56+
Granite.Code's edit feature was introduced in the [getting started tutorial](https://docs.granitecode.github.io/getting-started), where we saw how code can be easily made more readable. There are many other types of changes that can be made with Granite.Code. Some of these are available in the Granite.Code context menu in the code editor. This includes actions to:
57+
58+
* Fix grammar and spelling mistakes
59+
* Fix code errors
60+
* Optimize code
61+
* Add code comments
62+
63+
These menu items are a great way to access some of Granite.Code's editing features. They are also a great example of the different possibilities of the editing feature.
64+
65+
## Using keyboard shortcuts for common contexts
66+
67+
Granite.Code provides keyboard shortcuts for common contexts, which allow those contexts to be quickly used without needing to manually specify them. The main shortcuts to know are:
68+
69+
| Context | Mac | Windows/Linux |
70+
|--------------|-----|---------------|
71+
| Current file | Option+Return | Alt+Return |
72+
| Codebase | Command+Return | Ctrl+Return |

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
html_logo = "img/logo.svg"
7171

7272
# Set the explicit title of the HTML output
73-
html_title = 'Granite.code Documentation'
73+
html_title = 'Granite.Code Documentation'
7474

7575
# add custom files that are stored in _static
7676
html_css_files = ['granite.css']

docs/configuration.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Configuration
2+
3+
Granite.Code includes a range of configuration options, which can be used to tailor it to your needs. There are two types of settings:
4+
5+
## User settings
6+
7+
These can be opened from the settings button in the Granite.Code, or by using the **Granite.Code: Open Settings** command. Example user settings include:
8+
9+
* Wrapping codeblocks
10+
* Showing/hiding markdown formatting
11+
* Changing the font size
12+
13+
## VS Code extension settings
14+
15+
These can be opened from the VS Code settings, in the extensions section. VS Code extension settings include options such as:
16+
17+
* Check for model updates
18+
* Tab autocompletion
19+
* Show inline tips

docs/getting-started.md

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,96 @@
11
# Getting Started
22

3-
FIXME
3+
This tutorial provides an introduction to the main features of Granite.Code. To complete it, we recommend that you have a running instance of VS Code with the Granite.Code extension enabled and setup.
4+
5+
## Setup your workspace
6+
7+
For the best experience, we recommend moving the Granite.Code chat to the secondary sidebar, so that it is visible alongside the code editor. To do this:
8+
9+
1. If the secondary side bar is not visible, show it by clicking the **Toggle Secondary Side Bar** button in the VS Code header.
10+
2. Find the Granite.Code icon in the Activity Bar, then drag it to the secondary side bar header.
11+
12+
Granite.Code should now be located next to the VS Code editor area. With that done, let's explore Granite.Code's features.
13+
14+
## Ask questions
15+
16+
Granite.Code provides an interactive chat feature, which can be used to ask the Granite models questions.
17+
18+
To use the chat, either click on the "Ask anything" prompt, or use the **Command+L** / **Ctrl+L** keyboard shortcut. Then enter your question and press return.
19+
20+
The Granite.Code assistant can answer a range of question types, including general coding knowledge questions, advice on particular coding problems, learning best practices, and generating example code. Here are some example questions that you can try out:
21+
22+
1. TODO: general coding knowledge question. What is an X in Y?
23+
2. TODO: problem solving question. I am doing X. How do I do Y?
24+
3. TODO: best practices question. I am writing X. How do I make sure that it is performant?
25+
26+
Once you have asked a question, you can ask follow-up questions about the model's response. For example, TODO.
27+
28+
## Ask about a code section
29+
30+
In addition to being able to ask general coding questions, you can also ask Granite.Code questions about sections of code. This can be useful for understanding how a piece of code works, or for asking how a section of code can be improved.
31+
32+
To ask a question about a code section:
33+
34+
1. Highlight the code you want to ask a question about.
35+
2. Use the **Command+L** / **Ctrl+L** keyboard shortcut to start a chat, or use the **Granite.Code → Add Highlighted Code to Context** context menu item.
36+
3. The code section will be shown in the chat prompt.
37+
4. Enter a question about the code in the chat prompt, and press return.
38+
39+
You can try this using the code section below:
40+
41+
1. Copy the section to a Python file.
42+
2. Highlight the code, and add it to the chat.
43+
3. In the chat prompt, ask: "what sorting algorithm is this?".
44+
45+
```
46+
def sorting_algorithm(x):
47+
for i in range(len(x)):
48+
for j in range(len(x) - 1):
49+
if x[j] > x[j + 1]:
50+
x[j], x[j + 1] = x[j + 1], x[j]
51+
return x
52+
```
53+
54+
## Use Granite.Code to make changes
55+
56+
With Granite.Code it is possible to make code changes by giving editing instructions to the Granite models. An easy way to try this is to edit a code section:
57+
58+
1. In the editor, highlight the code you want to change.
59+
2. Use the **Command+E** / **Ctrl+E** keyboard shortcut to add the code section to the prompt and switch to edit mode.
60+
3. Describe how you want the code to be changed, then press return or click the **⏎ Enter** button.
61+
62+
You can try this with the code section below:
63+
64+
1. Copy the code section to the Python file you used earlier.
65+
2. Highlight the code and add it to the chat.
66+
3. In the chat, type "make this more readable", and press return.
67+
4. New code will be shown in the editor, alongside the existing code.
68+
5. Click Accept to accept the new code. Alternatively, you can use the **Command+Shift+Return** / **Ctrl+Shift+Return** keyboard shortcut to accept the changes.
69+
70+
```
71+
def sorting_algorithm(x):
72+
for i in range(len(x)):
73+
for j in range(len(x) - 1):
74+
if x[j] > x[j + 1]:
75+
x[j], x[j + 1] = x[j + 1], x[j]
76+
return x
77+
```
78+
79+
## Autocompletion
80+
81+
Granite.Code automatically makes suggestions as you type in the VS Code editor. Using the feature is simple: as you type you will see suggestions appear after the cursor. To accept a suggestion, just press the **Tab** key.
82+
83+
Let's use autocompletion to write assertions for the sorting algorithms from the previous examples:
84+
85+
* Copy the comment line below into the Python file that you used in the previous examples.
86+
* Place the cursor at the end of the line, then press **Return**.
87+
* When the suggestion is shown, press **Tab** to accept it.
88+
* You can keep pressing **Tab** to generate additional assertions for the other sorting algorithms in the file.
89+
90+
```
91+
# Basic assertion for sorting_algorithm...
92+
```
93+
94+
## Next steps
95+
96+
This guide has introduced some essential Granite.Code features. However, there is much more to Granite.Code, including techniques which will allow you to get the most out of the features that have just been introduced. When you're ready, head over to the [best practices guide](https://docs.granitecode.github.io/best-practices) to learn more.

docs/granite-models.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Granite Models
2+
3+
Granite.Code automatically selects and downloads [Granite models](https://www.ibm.com/granite) in order to provide the best experience possible. It also automatically updates the models when new versions become available.
4+
5+
To find out which model version you are currently using, click the **Models** button above the chat prompt.

docs/index.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22

33
# Granite.Code
44

5-
Granite.Code is a project by Red Hat and IBM to create an open-source AI code assistant using the IBM Granite model family, with the models running locally on your system.
5+
Granite.Code is an coding assistant for VS Code. It makes use of the [Granite family of AI models](https://www.ibm.com/granite) to provide a high quality AI assistant experience, while providing full control over privacy and information sharing. To achieve this, Granite.Code downloads and runs Granite models locally, so that no data is shared with other parties.
66

7-
The Granite.Code vscode extension is based on
8-
[Continue](https://github.com/continuedev/continue),
9-
but with a number of changes, including:
7+
Granite.Code can be installed as a VS Code extension: ee [setup](https://docs.granitecode.github.io/setup) to get started.
8+
9+
## Get in Touch
10+
11+
Issues can be reported in the [Granite.Code GitHub project](https://github.com/Granite-Code/granite-code/issues).
12+
13+
## About Us
14+
15+
Granite.Code is supported by [Red Hat](https://www.redhat.com/) and [IBM](https://www.ibm.com/), and is based on [Continue](https://github.com/continuedev/continue). The project is open source and contributions are welcome. For more details, see our [GitHub project](https://github.com/Granite-Code/).
1016

1117
```{toctree}
1218
:hidden:
13-
introduction.md
19+
setup.md
1420
getting-started.md
21+
best-practices.md
22+
configuration.md
23+
granite-models.md
1524
```

docs/introduction.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

docs/setup.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Setup
2+
3+
Granite.Code is available as an extension [on the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=redhat.granitecode), and can be installed on Windows, Mac, and Linux.
4+
5+
## Post-install setup
6+
7+
Once you have installed Granite.Code, it is necessary to get the latest Granite models ready for local use. To do this, Granite.Code launches a setup wizard which sets up the environment and downloads the models.
8+
9+
If you need to restart the setup wizard for any reason, it can be launched from the VS Code command palette using the `Granite.Code: Setup Granite as code assistant` command.
10+
11+
Once you have set up Granite.Code, we recommend that you try out the [getting started tutorial](https://docs.granitecode.github.io/getting-started).
12+
13+
## System requirements
14+
15+
Granite.Code should only be used with hardware that is capable of effectively running the Granite models.
16+
17+
Recommended hardware:
18+
19+
* Mac: Apple Silicon systems with at least 20GB memory
20+
* Linux and Windows: systems with a discrete NVIDIA or AMD GPU

0 commit comments

Comments
 (0)