GitHub Copilot integration

There are several ways in which Vadacode supports the interaction with Copilot. We have a specialized chat participant called Vadacoder, and a set of Vadalog-based custom instructions and command-specific prompts which can be installed in your workspace. Both features rely on the use of Copilot as-is, with off-the-shelf models and without the need of custom (e.g., fine-tuned) models.

copilot cover
Figure 1. Vadacode host several features for using Copilot.
All the features listed in this page are available if you have the GitHub Copilot extension installed and enabled in your workspace. Go to the GitHub Copilot extension for more information. Since VSCode 1.99, you can use both serviced and self-hosted LLMs.
The features listed in this page are experimental. Copilot integration is evolving very rapidly (see for example this VSCode release, where most of the changes are to Copilot integration), so features may be added, change or be removed in future releases.

Vadacoder

After the release of Custom Instructions, domain-specific chat participants like Vadacoder are less relevant, but still useful for some tasks. One example is chatting with Copilot about Vadalog without a .vada file context, as it is a language that is not widely known.

VS Code has several built-in chat participants like @vscode, @terminal, or @workspace. They are optimized to answer questions about their respective domains. Vadacode contributes a @vadacoder GitHub Copilot assistant that knows Vadalog.

To chat with Vadacoder, mention explicitly @vadacoder in GitHub Copilot chat prompt and write your questions. You can ask it to scaffold code, or you can paste code and have it explained.

But you can do more: @vadacoder supports specialized commands for common tasks.

/write command

If you want to swiftly generate some Vadalog program you can use the /write command. This allows you to specify programs in natural language and write them directly in Vadalog!

Let’s see how it works; paste this prompt:

@vadacoder /write Scaffold some facts for companies, like company(id, name, address) and ownerships, like owns(idCompanyA, idCompanyB, percent)

% Companies: company(ID, Name, Address)
company(1, "Acme Corp", "123 Main St").
company(2, "Beta Ltd", "456 Oak Ave").
company(3, "Gamma Inc", "789 Pine Rd").
company(4, "Delta LLC", "321 Maple Blvd").

% Ownerships: owns(OwnerID, OwnedID, Percent)
owns(1, 2, 60.0).
owns(2, 3, 75.0).
owns(3, 4, 50.0).
owns(1, 4, 10.0).

We can then expand the data. Try pasting this prompt:

@vadacoder /write Add three more companies in Italy which sell ice cream, and make company "1" control company 4.

% Add three more Italian ice cream companies
company(5, "Gelato Roma", "Via Veneto 10, Rome, Italy").
company(6, "Dolce Vita Gelateria", "Corso Italia 22, Milan, Italy").
company(7, "Fresco Gelato", "Piazza San Marco 5, Venice, Italy").

% Optionally, add a predicate to indicate what they sell
sells(5, "ice cream").
sells(6, "ice cream").
sells(7, "ice cream").

% Make company 1 control company 4 (assuming control means 50%+ ownership)
owns(1, 4, 51.0).

Good, now that’s some interesting data. To make it a bit more interesting, we can add some more info to existing companies, in-place:

@vadacoder /write we forgot to add activity sector to "company"!

% Add activity sector as the fourth argument: company(ID, Name, Address, Sector)
company(1, "Acme Corp", "123 Main St", "Manufacturing").
company(2, "Beta Ltd", "456 Oak Ave", "Consulting").
company(3, "Gamma Inc", "789 Pine Rd", "Technology").
company(4, "Delta LLC", "321 Maple Blvd", "Logistics").
company(5, "Gelato Roma", "Via Veneto 10, Rome, Italy", "Ice Cream").
company(6, "Dolce Vita Gelateria", "Corso Italia 22, Milan, Italy", "Ice Cream").
company(7, "Fresco Gelato", "Piazza San Marco 5, Venice, Italy", "Ice Cream").

Now it’s the time to write some logic:

@vadacoder /write Well, now get me competitors. Two companies are competitors if they are in the same field of activity.

% Two companies are competitors if they are in the same sector and have different IDs
competitor(X, Y) :- company(X, _, _, S), company(Y, _, _, S), X <> Y.

@output("competitor").

/manual command

Vadacoder is quite an expert in Vadalog!

Using the /manual command, you can ask it to explain Vadalog concepts, or to answer questions about the language. Let’s try it out:

@vadacoder /manual What is Vadalog’s reference fragment?

@vadacoder /manual Can I use aggregation in recursion?

@vadacoder /manual Explain to me how to use msum

@vadacoder /manual What available operators?

copilot manual
Figure 2. Asking questions about Vadalog to Vadacoder

Custom instructions and prompts

Vadacode ships with a set of pre-configured Copilot instructions and prompts that support logic programming in Vadalog.

These assets are not installed automatically because they need to be configured per-workspace. In yoour workspace, you can install them by running the command Add Vadalog Copilot Instructions & Prompts from the Command Palette (+Shift+P on macOS or Ctrl+Shift+P on Windows/Linux).

Custom instructions and prompts are activated only if you have the GitHub Copilot extension installed and enabled in your workspace, and you have a Vadalog file open (.vada`or `.vadanb). To be sure that Copilot is answering using Vadacode instructions, just verify which references are fetched during the response.
copilot references
Figure 3. Copilot used Vadacode references to answer our question.

Custom instructions

Vadacode ships with a set of custom instructions to further improve the responses of queries involving programming in Vadalog. Instead of manually including this context in every chat query, custom instructions automatically incorporate this information with every chat request.

Custom instructions are not taken into account for code completions (by design of VSCode Copilot integration).

Vadacode supports custom instructions for editing code in Vadalog language both in .vada and .vadanb files.

Custom prompts

Vadacode defines reusable prompts for common tasks; these prompts are stored in files are standalone prompts that you can run directly in chat. They describe the task to be performed (what should be done). Optionally, you can include tasks-specific guidelines about how the task should be performed, or you can reference custom instructions in the prompt file. Learn how to create prompt files.

/vadoc prompt

Vadacode ships with a handy /vadoc prompt that helps you write documentation for predicate atoms and keep your code understandable. This prompt is available in the vadacode/prompts folder, and you can run it by typing /vadoc in the chat.

To document a predicate, open Editor Inline Chat (+I on macOS or Ctrl+I on Windows/Linux) and just type /vadoc in the chat.

copilot vadoc prompt
Figure 4. Vadoc prompt in Editor Inline Chat

Copilot will then readily write the documentation for you, based on the predicate atom you are editing. You can then edit the documentation to your liking.

%% Aggregates the total percentage of shares that an `owner` controls over an `owned` company,
%% considering all possible intermediate entities.
%% @term {string} Owner Id of owner entity.
%% @term {string} Owned Id of owned entity.
%% @term {number} Percentage Total percentage of shares controlled by the owner.
total_controlled_shares(X,Y,J) :- controlled_shares(X,_,Y,P), J=msum(P).