(null);
29 | 
30 |   return (
31 |     
32 |       
69 |   );
70 | };
71 | 
--------------------------------------------------------------------------------
/lib/webview/src/component/CollapsedConversationView.tsx:
--------------------------------------------------------------------------------
 1 | import { webviewApi } from "@rubberduck/common";
 2 | import React from "react";
 3 | import { ConversationHeader } from "./ConversationHeader";
 4 | 
 5 | export const CollapsedConversationView: React.FC<{
 6 |   conversation: webviewApi.Conversation;
 7 |   onClick: () => void;
 8 | }> = ({ conversation, onClick }) => (
 9 |   
10 |     
11 |   
12 | );
13 | 
--------------------------------------------------------------------------------
/lib/webview/src/component/ConversationHeader.tsx:
--------------------------------------------------------------------------------
 1 | import { webviewApi } from "@rubberduck/common";
 2 | import { on } from "events";
 3 | import React from "react";
 4 | 
 5 | export const ConversationHeader: React.FC<{
 6 |   conversation: webviewApi.Conversation;
 7 |   onIconClick?: () => void;
 8 | }> = ({ conversation, onIconClick }) => {
 9 |   return (
10 |     
11 |       
12 |       {conversation.header.isTitleMessage ? (
13 |         {conversation.header.title}
14 |       ) : (
15 |         conversation.header.title
16 |       )}
17 |       {onIconClick && (
18 |         
19 |            
20 |           < i className="codicon codicon-eye inline" onClick={onIconClick} />
21 |         
22 |       )}
23 |     
24 |   );
25 | };
26 | 
--------------------------------------------------------------------------------
/lib/webview/src/component/ErrorMessage.tsx:
--------------------------------------------------------------------------------
 1 | import { webviewApi } from "@rubberduck/common";
 2 | import React from "react";
 3 | import ReactMarkdown from "react-markdown";
 4 | 
 5 | export function ErrorMessage({
 6 |   error,
 7 |   onClickDismiss,
 8 |   onClickRetry,
 9 | }: {
10 |   error: webviewApi.Error;
11 |   onClickDismiss: () => void;
12 |   onClickRetry: () => void;
13 | }) {
14 |   return typeof error === "string" ? (
15 |     
16 |       Error: {error}
17 |       
18 |         
19 |         Retry
20 |       
21 |     
22 |   ) : (
23 |     
24 |       
25 |         {error.title}
26 |       
27 |       
28 |         {error.message}
29 |       
30 |       
31 |         {!error.disableDismiss && (
32 |           
35 |         )}
36 |         {!error.disableRetry && (
37 |           
41 |         )}
42 |       
43 |     
28 |         {
29 |           onClickInsertPrompt ?
30 |             (
)
31 |             : (
)
32 |         }
33 | 
34 |         {(() => {
35 |           const type = content.type;
36 |           switch (type) {
37 |             case "messageExchange":
38 |               return (
39 |                 
45 |               );
46 |             case "instructionRefinement":
47 |               return (
48 |                 
54 |               );
55 |             default: {
56 |               const exhaustiveCheck: never = type;
57 |               throw new Error(`unsupported type: ${exhaustiveCheck}`);
58 |             }
59 |           }
60 |         })()}
61 | 
62 |         
63 |           
64 |             
69 |             
74 |           
75 |         
76 |       
20 |       {(() => {
21 |         const type = content.state.type;
22 |         switch (type) {
23 |           case "waitingForBotAnswer":
24 |             return (
25 |               <>
26 |                 
27 |                 
30 |               >
31 |             );
32 |           case "userCanRefineInstruction":
33 |             return (
34 |               <>
35 |                  onSendMessage(inputText)}
40 |                   shouldCreateNewLineOnEnter
41 |                 />
42 |                 
45 |               >
46 |             );
47 |           default: {
48 |             const exhaustiveCheck: never = type;
49 |             throw new Error(`unsupported type: ${exhaustiveCheck}`);
50 |           }
51 |         }
52 |       })()}
53 | 
54 |       {content.error && (
55 |         
60 |       )}
61 |     
62 |   );
63 | }
64 | 
--------------------------------------------------------------------------------
/lib/webview/src/component/MessageExchangeView.tsx:
--------------------------------------------------------------------------------
 1 | import { webviewApi } from "@rubberduck/common";
 2 | import React, { useState } from "react";
 3 | import ReactMarkdown from "react-markdown";
 4 | import { ChatInput } from "./ChatInput";
 5 | import { ErrorMessage } from "./ErrorMessage";
 6 | 
 7 | export function MessageExchangeView({
 8 |   content,
 9 |   onClickDismissError,
10 |   onClickRetry,
11 |   onSendMessage,
12 | }: {
13 |   content: webviewApi.MessageExchangeContent;
14 |   onSendMessage: (message: string) => void;
15 |   onClickDismissError: () => void;
16 |   onClickRetry: () => void;
17 | }) {
18 |   const [inputText, setInputText] = useState("");
19 | 
20 |   return (
21 |     
22 |       {content.messages.map((message, i) => (
23 |         
24 |           {message.author === "user" && message.content}
25 |           {message.author === "bot" && (
26 |             {message.content}
27 |           )}
28 |         
29 |       ))}
30 |       {(() => {
31 |         const type = content.state.type;
32 |         switch (type) {
33 |           case "waitingForBotAnswer":
34 |             return (
35 |               
36 |                 {content.state.botAction ?? ""}
37 |                 
38 |               
39 |             );
40 |           case "botAnswerStreaming":
41 |             return (
42 |               
43 |                 
44 |                   {content.state.partialAnswer ?? ""}
45 |                 
46 |                 
47 |               
48 |             );
49 |           case "userCanReply":
50 |             return (
51 |               
 0
55 |                     ? "Reply…"
56 |                     : "Ask…"
57 |                 }
58 |                 text={inputText}
59 |                 onChange={setInputText}
60 |                 onSubmit={() => {
61 |                   onSendMessage(inputText);
62 |                   setInputText("");
63 |                 }}
64 |               />
65 |             );
66 |           default: {
67 |             const exhaustiveCheck: never = type;
68 |             throw new Error(`unsupported type: ${exhaustiveCheck}`);
69 |           }
70 |         }
71 |       })()}
72 | 
73 |       {content.error && (
74 |         
79 |       )}
80 |     
 11 |     
 12 |   
 13 | );
 14 | 
 15 | export const ChatPanelView: React.FC<{
 16 |   sendMessage: SendMessage;
 17 |   panelState: webviewApi.PanelState;
 18 | }> = ({ panelState, sendMessage }) => {
 19 |   if (panelState == null) {
 20 |     return (
 21 |        sendMessage({ type: "startChat" })} />
 22 |     );
 23 |   }
 24 | 
 25 |   if (panelState.type !== "chat") {
 26 |     throw new Error(
 27 |       `Invalid panel state '${panelState.type}' (expected 'chat'))`
 28 |     );
 29 |   }
 30 | 
 31 |   if (!panelState.hasOpenAIApiKey) {
 32 |     return (
 33 |       
 34 |         
 37 |         
 38 |           Rubberduck uses the OpenAI API and requires an API key to work. You
 39 |           can get an API key from{" "}
 40 |           
 41 |             platform.openai.com/account/api-keys
 42 |           
 43 |         
 44 |       
 56 |       {panelState.conversations.reverse().map((conversation) =>
 57 |         panelState.selectedConversationId === conversation.id ? (
 58 |           
 62 |               sendMessage({
 63 |                 type: "sendMessage",
 64 |                 data: { id: conversation.id, message },
 65 |               })
 66 |             }
 67 |             onClickRetry={() =>
 68 |               sendMessage({
 69 |                 type: "retry",
 70 |                 data: { id: conversation.id },
 71 |               })
 72 |             }
 73 |             onClickDismissError={() =>
 74 |               sendMessage({
 75 |                 type: "dismissError",
 76 |                 data: { id: conversation.id },
 77 |               })
 78 |             }
 79 |             onClickDelete={() =>
 80 |               sendMessage({
 81 |                 type: "deleteConversation",
 82 |                 data: { id: conversation.id },
 83 |               })
 84 |             }
 85 |             onClickExport={() => {
 86 |               sendMessage({
 87 |                 type: "exportConversation",
 88 |                 data: { id: conversation.id },
 89 |               });
 90 |             }}
 91 |             onClickInsertPrompt={panelState.surfacePromptForOpenAIPlus ? () => {
 92 |               sendMessage({
 93 |                 type: "insertPromptIntoEditor",
 94 |                 data: { id: conversation.id },
 95 |               })
 96 |             } : undefined}
 97 |           />
 98 |         ) : (
 99 |           
103 |               sendMessage({
104 |                 type: "clickCollapsedConversation",
105 |                 data: { id: conversation.id },
106 |               })
107 |             }
108 |           />
109 |         )
110 |       )}
111 |     
112 |   );
113 | };
114 | 
--------------------------------------------------------------------------------
/lib/webview/src/panel/DiffPanelView.tsx:
--------------------------------------------------------------------------------
 1 | import { webviewApi } from "@rubberduck/common";
 2 | import React from "react";
 3 | import { DiffView } from "../component/DiffView";
 4 | import { SendMessage } from "../vscode/SendMessage";
 5 | 
 6 | export const DiffPanelView: React.FC<{
 7 |   sendMessage: SendMessage;
 8 |   panelState: webviewApi.PanelState;
 9 | }> = ({ panelState, sendMessage }) => {
10 |   if (panelState == null) {
11 |     return <>>;
12 |   }
13 | 
14 |   if (panelState.type !== "diff") {
15 |     throw new Error(
16 |       `Invalid panel state '${panelState.type}' (expected 'diff'))`
17 |     );
18 |   }
19 | 
20 |   return (
21 |     <>
22 |       
27 |       
34 |         
43 |       
44 |     >
45 |   );
46 | };
47 | 
--------------------------------------------------------------------------------
/lib/webview/src/vscode/SendMessage.ts:
--------------------------------------------------------------------------------
1 | import { vscodeApi } from "./VsCodeApi";
2 | import { webviewApi } from "@rubberduck/common";
3 | 
4 | export type SendMessage = (message: webviewApi.OutgoingMessage) => void;
5 | 
6 | export const sendMessage: SendMessage = (message) => {
7 |   vscodeApi.postMessage(message);
8 | };
9 | 
--------------------------------------------------------------------------------
/lib/webview/src/vscode/StateManager.ts:
--------------------------------------------------------------------------------
 1 | import { webviewApi } from "@rubberduck/common";
 2 | import { vscodeApi } from "./VsCodeApi";
 3 | 
 4 | let state: webviewApi.PanelState = undefined;
 5 | let updateListener: ((state: webviewApi.PanelState) => void) | undefined =
 6 |   undefined;
 7 | 
 8 | // safely load state from VS Code
 9 | const loadedState = vscodeApi.getState();
10 | try {
11 |   state = webviewApi.panelStateSchema.parse(loadedState);
12 | } catch (error) {
13 |   console.log({
14 |     loadedState,
15 |     error,
16 |   });
17 | }
18 | 
19 | const updateState = (newState: webviewApi.PanelState) => {
20 |   vscodeApi.setState(newState);
21 |   state = newState;
22 | 
23 |   if (updateListener != null) {
24 |     updateListener(state);
25 |   }
26 | };
27 | 
28 | window.addEventListener("message", (rawMessage: unknown) => {
29 |   const event = webviewApi.incomingMessageSchema.parse(rawMessage);
30 | 
31 |   const message = event.data;
32 |   if (message.type === "updateState") {
33 |     updateState(message.state);
34 |   }
35 | });
36 | 
37 | // exposed as Singleton that is managed outside of React
38 | // (to prevent schema change errors from breaking the UI)
39 | 
40 | export const registerUpdateListener = (
41 |   listener: (state: webviewApi.PanelState) => void
42 | ) => {
43 |   updateListener = listener;
44 | };
45 | 
46 | export const getState = () => state;
47 | 
--------------------------------------------------------------------------------
/lib/webview/src/vscode/VsCodeApi.ts:
--------------------------------------------------------------------------------
 1 | export type VsCodeApi = {
 2 |   /**
 3 |    * Post a message (i.e. send arbitrary data) to the owner of the webview.
 4 |    *
 5 |    * @param message Arbitrary data (must be JSON serializable) to send to the extension context.
 6 |    */
 7 |   postMessage(message: T): void;
 8 | 
 9 |   /**
10 |    * Get the persistent state stored for this webview.
11 |    *
12 |    * @return The current state or `undefined` if no state has been set.
13 |    */
14 |   getState(): T | undefined;
15 | 
16 |   /**
17 |    * Set the persistent state stored for this webview.
18 |    *
19 |    * @param state New persisted state. This must be a JSON serializable object. Can be retrieved
20 |    * using {@link getState}.
21 |    *
22 |    */
23 |   setState(state: T): T;
24 | };
25 | 
26 | declare const acquireVsCodeApi: () => VsCodeApi;
27 | 
28 | // keep as a global in the view, since it can only be acquired once
29 | export const vscodeApi = acquireVsCodeApi();
30 | 
--------------------------------------------------------------------------------
/lib/webview/src/webview.tsx:
--------------------------------------------------------------------------------
 1 | import { webviewApi } from "@rubberduck/common";
 2 | import * as React from "react";
 3 | import { createRoot } from "react-dom/client";
 4 | import { ChatPanelView } from "./panel/ChatPanelView";
 5 | import { DiffPanelView } from "./panel/DiffPanelView";
 6 | import { sendMessage } from "./vscode/SendMessage";
 7 | import * as StateManager from "./vscode/StateManager";
 8 | 
 9 | const rootElement = document.getElementById("root");
10 | 
11 | const panel = document.currentScript?.getAttribute("data-panel-id");
12 | const isStateReloadingEnabled =
13 |   document.currentScript?.getAttribute("data-state-reloading-enabled") ===
14 |   "true";
15 | 
16 | if (rootElement != undefined) {
17 |   const reactRoot = createRoot(rootElement);
18 | 
19 |   const render = (panelState?: webviewApi.PanelState) => {
20 |     try {
21 |       reactRoot?.render(
22 |         
23 |           {(() => {
24 |             switch (panel) {
25 |               case "chat":
26 |                 return (
27 |                   
31 |                 );
32 |               case "diff":
33 |                 return (
34 |                   
38 |                 );
39 |               default:
40 |                 return ;
41 |             }
42 |           })()}
43 |         
44 |       );
45 |     } catch (error) {
46 |       console.error(error);
47 |     }
48 |   };
49 | 
50 |   render(isStateReloadingEnabled ? StateManager.getState() : undefined);
51 |   StateManager.registerUpdateListener(render);
52 | }
53 | 
--------------------------------------------------------------------------------
/lib/webview/tsconfig.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "compilerOptions": {
 3 |     "lib": ["dom", "es2020"],
 4 |     "jsx": "react",
 5 |     "allowSyntheticDefaultImports": true,
 6 |     "esModuleInterop": true,
 7 |     "target": "es2020",
 8 |     "strict": true,
 9 |     "declaration": true,
10 |     "sourceMap": true,
11 |     "moduleResolution": "node",
12 |     "rootDir": "./src",
13 |     "outDir": "./build"
14 |   },
15 |   "include": ["src/**/*.ts", "src/**/*.tsx"]
16 | }
17 | 
--------------------------------------------------------------------------------
/lint-staged.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 |   "*.{ts,json,md}": "prettier --write",
3 | };
4 | 
--------------------------------------------------------------------------------
/nx.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "extends": "nx/presets/npm.json",
 3 |   "$schema": "./node_modules/nx/schemas/nx-schema.json",
 4 |   "tasksRunnerOptions": {
 5 |     "default": {
 6 |       "runner": "nx/tasks-runners/default",
 7 |       "options": {
 8 |         "cacheableOperations": ["build", "lint", "test", "e2e"]
 9 |       }
10 |     }
11 |   },
12 |   "cli": {
13 |     "packageManager": "pnpm"
14 |   }
15 | }
16 | 
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "name": "rubberduck-vscode-root",
 3 |   "version": "0.0.0",
 4 |   "license": "MIT",
 5 |   "scripts": {
 6 |     "prepare": "husky install",
 7 |     "build-all": "pnpm nx run-many --target=build",
 8 |     "build-extension": "pnpm nx run vscode:build",
 9 |     "test": "pnpm nx run extension:test",
10 |     "test-watch": "pnpm nx run extension:test-watch",
11 |     "package": "pnpm nx run vscode:package",
12 |     "deploy:vscode": "pnpm nx run vscode:publish-vscode",
13 |     "deploy:ovsx": "pnpm nx run vscode:publish-ovsx"
14 |   },
15 |   "private": true,
16 |   "devDependencies": {
17 |     "@types/node": "^18.11.18",
18 |     "@typescript-eslint/eslint-plugin": "^5.49.0",
19 |     "@typescript-eslint/parser": "^5.49.0",
20 |     "@vscode/vsce": "2.16.0",
21 |     "esbuild": "0.16.10",
22 |     "eslint": "^8.32.0",
23 |     "eslint-config-prettier": "8.6.0",
24 |     "husky": "^8.0.0",
25 |     "lint-staged": "13.1.0",
26 |     "nx": "15.4.1",
27 |     "ovsx": "0.8.0",
28 |     "prettier": "2.8.3",
29 |     "typescript": "4.9.4",
30 |     "vitest": "0.28.3"
31 |   },
32 |   "workspaces": [
33 |     "app/*",
34 |     "lib/*"
35 |   ]
36 | }
37 | 
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 |   - 'app/*'
3 |   - 'lib/*'
4 | 
--------------------------------------------------------------------------------
/project.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "targets": {
 3 |     "lint": {
 4 |       "executor": "nx:run-commands",
 5 |       "options": {
 6 |         "command": "eslint **/src/**"
 7 |       }
 8 |     }
 9 |   }
10 | }
11 | 
--------------------------------------------------------------------------------
/template/chat/chat-de.rdt.md:
--------------------------------------------------------------------------------
 1 | # AI Chat in German
 2 | 
 3 | This template lets you chat with Rubberduck in German.
 4 | 
 5 | ## Template
 6 | 
 7 | ### Configuration
 8 | 
 9 | ```json conversation-template
10 | {
11 |   "id": "chat-de",
12 |   "engineVersion": 0,
13 |   "label": "Starte eine Unterhaltung",
14 |   "description": "Starte eine Unterhaltung mit Rubberduck.",
15 |   "header": {
16 |     "title": "Neue Unterhaltung",
17 |     "useFirstMessageAsTitle": true,
18 |     "icon": {
19 |       "type": "codicon",
20 |       "value": "comment-discussion"
21 |     }
22 |   },
23 |   "variables": [
24 |     {
25 |       "name": "selectedText",
26 |       "time": "conversation-start",
27 |       "type": "selected-text"
28 |     },
29 |     {
30 |       "name": "lastMessage",
31 |       "time": "message",
32 |       "type": "message",
33 |       "property": "content",
34 |       "index": -1
35 |     }
36 |   ],
37 |   "response": {
38 |     "placeholder": "Antworte",
39 |     "maxTokens": 1024,
40 |     "stop": ["Roboter:", "Entwickler:"]
41 |   }
42 | }
43 | ```
44 | 
45 | ### Response Prompt
46 | 
47 | ```template-response
48 | ## Anweisungen
49 | Setze die folgende Unterhaltung fort.
50 | Achte besonders auf die aktuelle Entwickler-Nachricht.
51 | 
52 | ## Aktuelle Nachricht
53 | Entwickler: {{lastMessage}}
54 | 
55 | {{#if selectedText}}
56 | ## Selektierter Quelltext
57 | \`\`\`
58 | {{selectedText}}
59 | \`\`\`
60 | {{/if}}
61 | 
62 | ## Unterhaltung
63 | {{#each messages}}
64 | {{#if (eq author "bot")}}
65 | Roboter: {{content}}
66 | {{else}}
67 | Entwickler: {{content}}
68 | {{/if}}
69 | {{/each}}
70 | 
71 | ## Aufgabe
72 | Schreibe eine Antwort, welche die Unterhaltung fortsetzt.
73 | Achte besonders auf die aktuelle Entwickler-Nachricht.
74 | Ziehe die Möglichkeit in Betracht, dass es keine Lösung geben könnte.
75 | Frage nach, wenn die Nachricht keinen Sinn ergibt oder mehr Informationen benötigt werden.
76 | Benutze den Stil eines Dokumentationsartikels.
77 | Binde Code-Schnipsel (mit Markdown) und Beispiele ein, wo es angebracht ist.
78 | 
79 | ## Antwort
80 | Roboter:
81 | ```
82 | 
--------------------------------------------------------------------------------
/template/chat/chat-en.rdt.md:
--------------------------------------------------------------------------------
 1 | # AI Chat in English
 2 | 
 3 | This template lets you chat with Rubberduck in English.
 4 | 
 5 | ## Template
 6 | 
 7 | ### Configuration
 8 | 
 9 | ```json conversation-template
10 | {
11 |   "id": "chat-en",
12 |   "engineVersion": 0,
13 |   "label": "Start chat",
14 |   "description": "Start a basic chat with Rubberduck.",
15 |   "header": {
16 |     "title": "New chat",
17 |     "useFirstMessageAsTitle": true,
18 |     "icon": {
19 |       "type": "codicon",
20 |       "value": "comment-discussion"
21 |     }
22 |   },
23 |   "variables": [
24 |     {
25 |       "name": "selectedText",
26 |       "time": "conversation-start",
27 |       "type": "selected-text"
28 |     },
29 |     {
30 |       "name": "lastMessage",
31 |       "time": "message",
32 |       "type": "message",
33 |       "property": "content",
34 |       "index": -1
35 |     }
36 |   ],
37 |   "response": {
38 |     "maxTokens": 1024,
39 |     "stop": ["Bot:", "Developer:"]
40 |   }
41 | }
42 | ```
43 | 
44 | ### Response Prompt
45 | 
46 | ```template-response
47 | ## Instructions
48 | Continue the conversation below.
49 | Pay special attention to the current developer request.
50 | 
51 | ## Current Request
52 | Developer: {{lastMessage}}
53 | 
54 | {{#if selectedText}}
55 | ## Selected Code
56 | \`\`\`
57 | {{selectedText}}
58 | \`\`\`
59 | {{/if}}
60 | 
61 | ## Conversation
62 | {{#each messages}}
63 | {{#if (eq author "bot")}}
64 | Bot: {{content}}
65 | {{else}}
66 | Developer: {{content}}
67 | {{/if}}
68 | {{/each}}
69 | 
70 | ## Task
71 | Write a response that continues the conversation.
72 | Stay focused on current developer request.
73 | Consider the possibility that there might not be a solution.
74 | Ask for clarification if the message does not make sense or more input is needed.
75 | Use the style of a documentation article.
76 | Omit any links.
77 | Include code snippets (using Markdown) and examples where appropriate.
78 | 
79 | ## Response
80 | Bot:
81 | ```
82 | 
--------------------------------------------------------------------------------
/template/chat/chat-fr.rdt.md:
--------------------------------------------------------------------------------
 1 | # AI Chat in French
 2 | 
 3 | This template lets you chat with Rubberduck in French.
 4 | 
 5 | ## Template
 6 | 
 7 | ### Configuration
 8 | 
 9 | ```json conversation-template
10 | {
11 |   "id": "chat-fr",
12 |   "engineVersion": 0,
13 |   "label": "Commencer une discussion",
14 |   "description": "Commencer une discussion avec Rubberduck.",
15 |   "header": {
16 |     "title": "Nouvelle discussion",
17 |     "useFirstMessageAsTitle": true,
18 |     "icon": {
19 |       "type": "codicon",
20 |       "value": "comment-discussion"
21 |     }
22 |   },
23 |   "variables": [
24 |     {
25 |       "name": "selectedText",
26 |       "time": "conversation-start",
27 |       "type": "selected-text"
28 |     },
29 |     {
30 |       "name": "lastMessage",
31 |       "time": "message",
32 |       "type": "message",
33 |       "property": "content",
34 |       "index": -1
35 |     }
36 |   ],
37 |   "response": {
38 |     "maxTokens": 1024,
39 |     "stop": ["Robot:", "Développeur:"]
40 |   }
41 | }
42 | ```
43 | 
44 | ### Response Prompt
45 | 
46 | ```template-response
47 | ## Instructions
48 | Continue la conversation ci-dessous.
49 | Fais particulièrement attention aux requêtes en cours du développeur.
50 | 
51 | ## Requête en cours
52 | Développeur: {{lastMessage}}
53 | 
54 | {{#if selectedText}}
55 | ## Code Sélectionné
56 | \`\`\`
57 | {{selectedText}}
58 | \`\`\`
59 | {{/if}}
60 | 
61 | ## Conversation
62 | {{#each messages}}
63 | {{#if (eq author "bot")}}
64 | Robot: {{content}}
65 | {{else}}
66 | Développeur: {{content}}
67 | {{/if}}
68 | {{/each}}
69 | 
70 | ## Tâche
71 | Écris une réponse qui poursuit la conversation.
72 | Fais particulièrement attention à la requête en cours du développeur.
73 | Considère la possibilité qu’il n’y ait pas de solution possible.
74 | Demande des clarifications si le message n’a pas de sens ou que plus de données sont nécessaires pour répondre.
75 | N’inclus aucun lien.
76 | Inclus des snippets de code (en Markdown) et des exemples lorsque c’est approprié.
77 | 
78 | ## Réponse
79 | Robot:
80 | ```
81 | 
--------------------------------------------------------------------------------
/template/experimental/find-code-rubberduck.rdt.md:
--------------------------------------------------------------------------------
 1 | # Find code
 2 | 
 3 | ## Template
 4 | 
 5 | ### Configuration
 6 | 
 7 | ```json conversation-template
 8 | {
 9 |   "id": "find-code-rubberduck",
10 |   "engineVersion": 0,
11 |   "label": "Find code",
12 |   "description": "Find code in the Rubberduck codebase.",
13 |   "header": {
14 |     "title": "Find code",
15 |     "useFirstMessageAsTitle": true,
16 |     "icon": {
17 |       "type": "codicon",
18 |       "value": "search"
19 |     }
20 |   },
21 |   "variables": [
22 |     {
23 |       "name": "lastMessage",
24 |       "time": "message",
25 |       "type": "message",
26 |       "property": "content",
27 |       "index": -1
28 |     }
29 |   ],
30 |   "response": {
31 |     "retrievalAugmentation": {
32 |       "type": "similarity-search",
33 |       "variableName": "searchResults",
34 |       "query": "{{lastMessage}}",
35 |       "source": "embedding-file",
36 |       "file": "rubberduck-repository.json",
37 |       "threshold": 0.7,
38 |       "maxResults": 5
39 |     },
40 |     "maxTokens": 2048,
41 |     "stop": ["Bot:", "Developer:"]
42 |   }
43 | }
44 | ```
45 | 
46 | ### Response Prompt
47 | 
48 | ```template-response
49 | ## Instructions
50 | Look at the search result and summarize where the code that matches the query is located.
51 | 
52 | ## Query
53 | {{lastMessage}}
54 | 
55 | ## Search Results
56 | {{#each searchResults}}
57 | #### {{file}}
58 | \`\`\`
59 | {{content}}
60 | \`\`\`
61 | {{/each}}
62 | 
63 | ## Task
64 | Summarize where the code that matches the query is located using the search results.
65 | 
66 | ## Response
67 | Bot:
68 | ```
69 | 
--------------------------------------------------------------------------------
/template/fun/code-sonnet.rdt.md:
--------------------------------------------------------------------------------
  1 | # Code Sonnet
  2 | 
  3 | Describe the selected code in a Shakespeare sonnet.
  4 | 
  5 | ## Template
  6 | 
  7 | ### Configuration
  8 | 
  9 | ```json conversation-template
 10 | {
 11 |   "id": "code-sonnet",
 12 |   "engineVersion": 0,
 13 |   "label": "Write a code sonnet",
 14 |   "tags": ["fun"],
 15 |   "description": "Describe the selected code, Shakespeare style.",
 16 |   "header": {
 17 |     "title": "Code Sonnet ({{location}})",
 18 |     "icon": {
 19 |       "type": "codicon",
 20 |       "value": "feedback"
 21 |     }
 22 |   },
 23 |   "variables": [
 24 |     {
 25 |       "name": "selectedText",
 26 |       "time": "conversation-start",
 27 |       "type": "selected-text",
 28 |       "constraints": [{ "type": "text-length", "min": 1 }]
 29 |     },
 30 |     {
 31 |       "name": "location",
 32 |       "time": "conversation-start",
 33 |       "type": "selected-location-text"
 34 |     }
 35 |   ],
 36 |   "initialMessage": {
 37 |     "placeholder": "Composing poetry",
 38 |     "maxTokens": 1024,
 39 |     "temperature": 0.6
 40 |   },
 41 |   "response": {
 42 |     "maxTokens": 512,
 43 |     "stop": ["Shakespeare:", "Developer:"],
 44 |     "temperature": 0.4
 45 |   }
 46 | }
 47 | ```
 48 | 
 49 | ### Initial Message Prompt
 50 | 
 51 | ```template-initial-message
 52 | ## Instructions
 53 | You are Shakespeare.
 54 | Write a sonnet about the code below.
 55 | 
 56 | ## Code
 57 | \`\`\`
 58 | {{selectedText}}
 59 | \`\`\`
 60 | 
 61 | ## Task
 62 | Write a sonnet about the code.
 63 | 
 64 | ## Sonnet
 65 | 
 66 | ```
 67 | 
 68 | ### Response Prompt
 69 | 
 70 | ```template-response
 71 | ## Instructions
 72 | You are Shakespeare.
 73 | Continue the conversation.
 74 | Use 16th century English.
 75 | 
 76 | {{#if selectedText}}
 77 | ## Code
 78 | \`\`\`
 79 | {{selectedText}}
 80 | \`\`\`
 81 | {{/if}}
 82 | 
 83 | ## Sonnet
 84 | {{firstMessage}}
 85 | 
 86 | ## Conversation
 87 | {{#each messages}}
 88 | {{#if (neq @index 0)}}
 89 | {{#if (eq author "bot")}}
 90 | Shakespeare: {{content}}
 91 | {{else}}
 92 | Developer: {{content}}
 93 | {{/if}}
 94 | {{/if}}
 95 | {{/each}}
 96 | 
 97 | ## Task
 98 | Write a response that continues the conversation.
 99 | Use 16th century English.
100 | Reference events from the 16th century when possible.
101 | 
102 | ## Response
103 | Shakespeare:
104 | ```
105 | 
--------------------------------------------------------------------------------
/template/fun/drunken-pirate.rdt.md:
--------------------------------------------------------------------------------
  1 | # Drunken Pirate
  2 | 
  3 | This template is a conversation between a developer and a drunken pirate. The drunken pirate starts by describing the selected code.
  4 | 
  5 | ## Template
  6 | 
  7 | ### Configuration
  8 | 
  9 | ```json conversation-template
 10 | {
 11 |   "id": "drunken-pirate",
 12 |   "engineVersion": 0,
 13 |   "label": "Ask a drunken pirate",
 14 |   "tags": ["fun"],
 15 |   "description": "Ask a drunken pirate about the meaning of your code",
 16 |   "header": {
 17 |     "title": "Drunken Pirate ({{location}})",
 18 |     "icon": {
 19 |       "type": "codicon",
 20 |       "value": "feedback"
 21 |     }
 22 |   },
 23 |   "variables": [
 24 |     {
 25 |       "name": "selectedText",
 26 |       "time": "conversation-start",
 27 |       "type": "selected-text",
 28 |       "constraints": [{ "type": "text-length", "min": 1 }]
 29 |     },
 30 |     {
 31 |       "name": "location",
 32 |       "time": "conversation-start",
 33 |       "type": "selected-location-text"
 34 |     },
 35 |     {
 36 |       "name": "lastMessage",
 37 |       "time": "message",
 38 |       "type": "message",
 39 |       "property": "content",
 40 |       "index": -1
 41 |     },
 42 |     {
 43 |       "name": "botRole",
 44 |       "time": "conversation-start",
 45 |       "type": "constant",
 46 |       "value": "drunken pirate"
 47 |     }
 48 |   ],
 49 |   "initialMessage": {
 50 |     "placeholder": "Drinking rum",
 51 |     "maxTokens": 512,
 52 |     "temperature": 0.8
 53 |   },
 54 |   "response": {
 55 |     "maxTokens": 1024,
 56 |     "stop": ["Drunken Pirate:", "Developer:"],
 57 |     "temperature": 0.7
 58 |   }
 59 | }
 60 | ```
 61 | 
 62 | ### Initial Message Prompt
 63 | 
 64 | ```template-initial-message
 65 | ## Instructions
 66 | You are a {{botRole}}.
 67 | Describe the code below.
 68 | 
 69 | ## Selected Code
 70 | \`\`\`
 71 | {{selectedText}}
 72 | \`\`\`
 73 | 
 74 | ## Task
 75 | You are a {{botRole}}.
 76 | Describe the code.
 77 | You pirate speak and refer to sailing and the sea where possible.
 78 | 
 79 | ## Description
 80 | 
 81 | ```
 82 | 
 83 | ### Response Prompt
 84 | 
 85 | ```template-response
 86 | ## Instructions
 87 | You are a {{botRole}}.
 88 | Continue the conversation.
 89 | 
 90 | ## Current Request
 91 | Developer: {{lastMessage}}
 92 | 
 93 | {{#if selectedText}}
 94 | ## Selected Code
 95 | \`\`\`
 96 | {{selectedText}}
 97 | \`\`\`
 98 | {{/if}}
 99 | 
100 | ## Conversation
101 | {{#each messages}}
102 | {{#if (eq author "bot")}}
103 | {{botRole}}: {{content}}
104 | {{else}}
105 | Developer: {{content}}
106 | {{/if}}
107 | {{/each}}
108 | 
109 | ## Task
110 | You are a {{botRole}}.
111 | Write a response that continues the conversation.
112 | Use pirate speak and refer to sailing and the sea where possible.
113 | 
114 | ## Response
115 | {{botRole}}:
116 | ```
117 | 
--------------------------------------------------------------------------------
/template/task/diagnose-errors.rdt.md:
--------------------------------------------------------------------------------
  1 | # Explain Code
  2 | 
  3 | Diagnoses any errors or warnings the selected code.
  4 | 
  5 | ## Template
  6 | 
  7 | ### Configuration
  8 | 
  9 | ```json conversation-template
 10 | {
 11 |   "id": "diagnose-errors",
 12 |   "engineVersion": 0,
 13 |   "label": "Diagnose Errors",
 14 |   "tags": ["debug"],
 15 |   "description": "Diagnose errors and warnings in the selected code.",
 16 |   "header": {
 17 |     "title": "Diagnose Errors ({{location}})",
 18 |     "icon": {
 19 |       "type": "codicon",
 20 |       "value": "search-fuzzy"
 21 |     }
 22 |   },
 23 |   "variables": [
 24 |     {
 25 |       "name": "selectedTextWithDiagnostics",
 26 |       "time": "conversation-start",
 27 |       "type": "selected-text-with-diagnostics",
 28 |       "severities": ["error", "warning"],
 29 |       "constraints": [{ "type": "text-length", "min": 1 }]
 30 |     },
 31 |     {
 32 |       "name": "location",
 33 |       "time": "conversation-start",
 34 |       "type": "selected-location-text"
 35 |     },
 36 |     {
 37 |       "name": "firstMessage",
 38 |       "time": "message",
 39 |       "type": "message",
 40 |       "property": "content",
 41 |       "index": 0
 42 |     },
 43 |     {
 44 |       "name": "lastMessage",
 45 |       "time": "message",
 46 |       "type": "message",
 47 |       "property": "content",
 48 |       "index": -1
 49 |     }
 50 |   ],
 51 |   "initialMessage": {
 52 |     "placeholder": "Diagnosing errors",
 53 |     "maxTokens": 512
 54 |   },
 55 |   "response": {
 56 |     "maxTokens": 1024,
 57 |     "stop": ["Bot:", "Developer:"]
 58 |   }
 59 | }
 60 | ```
 61 | 
 62 | ### Initial Message Prompt
 63 | 
 64 | ```template-initial-message
 65 | ## Instructions
 66 | Read through the errors and warnings in the code below.
 67 | 
 68 | ## Selected Code
 69 | \`\`\`
 70 | {{selectedTextWithDiagnostics}}
 71 | \`\`\`
 72 | 
 73 | ## Task
 74 | For each error or warning, write a paragraph that describes the most likely cause and a potential fix.
 75 | Include code snippets where appropriate.
 76 | 
 77 | ## Answer
 78 | 
 79 | ```
 80 | 
 81 | ### Response Prompt
 82 | 
 83 | ```template-response
 84 | ## Instructions
 85 | Continue the conversation below.
 86 | Pay special attention to the current developer request.
 87 | 
 88 | ## Current Request
 89 | Developer: {{lastMessage}}
 90 | 
 91 | {{#if selectedText}}
 92 | ## Selected Code
 93 | \`\`\`
 94 | {{selectedTextWithDiagnostics}}
 95 | \`\`\`
 96 | {{/if}}
 97 | 
 98 | ## Code Summary
 99 | {{firstMessage}}
100 | 
101 | ## Conversation
102 | {{#each messages}}
103 | {{#if (neq @index 0)}}
104 | {{#if (eq author "bot")}}
105 | Bot: {{content}}
106 | {{else}}
107 | Developer: {{content}}
108 | {{/if}}
109 | {{/if}}
110 | {{/each}}
111 | 
112 | ## Task
113 | Write a response that continues the conversation.
114 | Stay focused on current developer request.
115 | Consider the possibility that there might not be a solution.
116 | Ask for clarification if the message does not make sense or more input is needed.
117 | Use the style of a documentation article.
118 | Omit any links.
119 | Include code snippets (using Markdown) and examples where appropriate.
120 | 
121 | ## Response
122 | Bot:
123 | ```
124 | 
--------------------------------------------------------------------------------
/template/task/document-code.rdt.md:
--------------------------------------------------------------------------------
  1 | # Document Code
  2 | 
  3 | Document the selected code.
  4 | 
  5 | ## Template
  6 | 
  7 | ### Configuration
  8 | 
  9 | ````json conversation-template
 10 | {
 11 |   "id": "document-code",
 12 |   "engineVersion": 0,
 13 |   "label": "Document Code",
 14 |   "tags": ["generate", "document"],
 15 |   "description": "Document the selected code.",
 16 |   "header": {
 17 |     "title": "Document Code {{location}}",
 18 |     "icon": {
 19 |       "type": "codicon",
 20 |       "value": "output"
 21 |     }
 22 |   },
 23 |   "variables": [
 24 |     {
 25 |       "name": "selectedText",
 26 |       "time": "conversation-start",
 27 |       "type": "selected-text",
 28 |       "constraints": [{ "type": "text-length", "min": 1 }]
 29 |     },
 30 |     {
 31 |       "name": "language",
 32 |       "time": "conversation-start",
 33 |       "type": "language",
 34 |       "constraints": [{ "type": "text-length", "min": 1 }]
 35 |     }
 36 |   ],
 37 |   "chatInterface": "instruction-refinement",
 38 |   "initialMessage": {
 39 |     "placeholder": "Documenting selection",
 40 |     "maxTokens": 2048,
 41 |     "stop": ["```"],
 42 |     "completionHandler": {
 43 |       "type": "active-editor-diff",
 44 |       "botMessage": "Generated documentation."
 45 |     }
 46 |   },
 47 |   "response": {
 48 |     "placeholder": "Documenting selection",
 49 |     "maxTokens": 2048,
 50 |     "stop": ["```"],
 51 |     "completionHandler": {
 52 |       "type": "active-editor-diff",
 53 |       "botMessage": "Generated documentation."
 54 |     }
 55 |   }
 56 | }
 57 | ````
 58 | 
 59 | ### Initial Message Prompt
 60 | 
 61 | ```template-initial-message
 62 | ## Instructions
 63 | Document the code on function/method/class level.
 64 | Avoid line comments.
 65 | The programming language is {{language}}.
 66 | 
 67 | ## Code
 68 | \`\`\`
 69 | {{selectedText}}
 70 | \`\`\`
 71 | 
 72 | ## Documented Code
 73 | \`\`\`
 74 | 
 75 | ```
 76 | 
 77 | ### Response Prompt
 78 | 
 79 | ```template-response
 80 | ## Instructions
 81 | Document the code on function/method/class level.
 82 | Avoid line comments.
 83 | The programming language is {{language}}.
 84 | 
 85 | Consider the following instructions:
 86 | {{#each messages}}
 87 | {{#if (eq author "user")}}
 88 | {{content}}
 89 | {{/if}}
 90 | {{/each}}
 91 | 
 92 | ## Code
 93 | \`\`\`
 94 | {{selectedText}}
 95 | \`\`\`
 96 | 
 97 | ## Documented Code
 98 | \`\`\`
 99 | 
100 | ```
101 | 
--------------------------------------------------------------------------------
/template/task/edit-code.rdt.md:
--------------------------------------------------------------------------------
 1 | # Edit Code
 2 | 
 3 | Generate code using instructions.
 4 | 
 5 | ## Template
 6 | 
 7 | ### Configuration
 8 | 
 9 | ````json conversation-template
10 | {
11 |   "id": "edit-code",
12 |   "engineVersion": 0,
13 |   "label": "Edit Code",
14 |   "tags": ["edit"],
15 |   "description": "Instruct Rubberduck to edit the code. Creates a diff that you can review.",
16 |   "header": {
17 |     "title": "Edit Code {{location}}",
18 |     "icon": {
19 |       "type": "codicon",
20 |       "value": "edit"
21 |     }
22 |   },
23 |   "chatInterface": "instruction-refinement",
24 |   "variables": [
25 |     {
26 |       "name": "selectedText",
27 |       "time": "conversation-start",
28 |       "type": "selected-text",
29 |       "constraints": [{ "type": "text-length", "min": 1 }]
30 |     }
31 |   ],
32 |   "response": {
33 |     "placeholder": "Generating edit",
34 |     "maxTokens": 1536,
35 |     "stop": ["```"],
36 |     "completionHandler": {
37 |       "type": "active-editor-diff",
38 |       "botMessage": "Generated edit."
39 |     }
40 |   }
41 | }
42 | ````
43 | 
44 | ### Response Prompt
45 | 
46 | ```template-response
47 | ## Instructions
48 | Edit the code below as follows:
49 | {{#each messages}}
50 | {{#if (eq author "user")}}
51 | {{content}}
52 | {{/if}}
53 | {{/each}}
54 | 
55 | ## Code
56 | \`\`\`
57 | {{selectedText}}
58 | \`\`\`
59 | 
60 | ## Answer
61 | \`\`\`
62 | 
63 | ```
64 | 
--------------------------------------------------------------------------------
/template/task/explain-code-w-context.rdt.md:
--------------------------------------------------------------------------------
  1 | # Explain Code
  2 | 
  3 | Explain the selected code.
  4 | 
  5 | ## Template
  6 | 
  7 | ### Configuration
  8 | 
  9 | ```json conversation-template
 10 | {
 11 |   "id": "explain-code-with-context",
 12 |   "engineVersion": 0,
 13 |   "label": "Explain Code with Context",
 14 |   "description": "Explain the selected code in context of all the open files.",
 15 |   "tags": ["debug", "understand"],
 16 |   "header": {
 17 |     "title": "Explain Code ({{location}}) in context",
 18 |     "icon": {
 19 |       "type": "codicon",
 20 |       "value": "book"
 21 |     }
 22 |   },
 23 |   "variables": [
 24 |     {
 25 |       "name": "openFiles",
 26 |       "time": "conversation-start",
 27 |       "type": "context"
 28 |     },
 29 |     {
 30 |       "name": "selectedText",
 31 |       "time": "conversation-start",
 32 |       "type": "selected-text",
 33 |       "constraints": [{ "type": "text-length", "min": 1 }]
 34 |     },
 35 |     {
 36 |       "name": "location",
 37 |       "time": "conversation-start",
 38 |       "type": "selected-location-text"
 39 |     },
 40 |     {
 41 |       "name": "lastMessage",
 42 |       "time": "message",
 43 |       "type": "message",
 44 |       "property": "content",
 45 |       "index": -1
 46 |     }
 47 |   ],
 48 |   "response": {
 49 |     "maxTokens": 2048,
 50 |     "stop": ["Bot:", "Developer:"]
 51 |   }
 52 | }
 53 | ```
 54 | 
 55 | ### Response Prompt
 56 | 
 57 | ```template-response
 58 | ## Instructions
 59 | Continue the conversation below.
 60 | Pay special attention to the current developer request.
 61 | 
 62 | ## Current Request
 63 | Developer: {{lastMessage}}
 64 | 
 65 | {{#if selectedText}}
 66 | ## Selected Code
 67 | \`\`\`{{language}}
 68 | {{selectedText}}
 69 | \`\`\`
 70 | {{/if}}
 71 | 
 72 | ## Code Summary
 73 | ## Open Files
 74 | {{#each openFiles}}
 75 | ### File: {{name}}
 76 | \`\`\`{{language}}
 77 | {{content}}
 78 | \`\`\`
 79 | {{/each}}
 80 | 
 81 | ## Conversation
 82 | {{#each messages}}
 83 | {{#if (neq @index 0)}}
 84 | {{#if (eq author "bot")}}
 85 | Bot: {{content}}
 86 | {{else}}
 87 | Developer: {{content}}
 88 | {{/if}}
 89 | {{/if}}
 90 | {{/each}}
 91 | 
 92 | ## Task
 93 | Write a response that continues the conversation.
 94 | Stay focused on current developer request.
 95 | Consider the possibility that there might not be a solution.
 96 | Ask for clarification if the message does not make sense or more input is needed.
 97 | Use the style of a documentation article.
 98 | Omit any links.
 99 | Include code snippets (using Markdown) and examples where appropriate.
100 | 
101 | ## Response
102 | Bot:
103 | ```
104 | 
--------------------------------------------------------------------------------
/template/task/explain-code.rdt.md:
--------------------------------------------------------------------------------
  1 | # Explain Code
  2 | 
  3 | Explain the selected code.
  4 | 
  5 | ## Template
  6 | 
  7 | ### Configuration
  8 | 
  9 | ```json conversation-template
 10 | {
 11 |   "id": "explain-code",
 12 |   "engineVersion": 0,
 13 |   "label": "Explain Code",
 14 |   "description": "Explain the selected code.",
 15 |   "tags": ["debug", "understand"],
 16 |   "header": {
 17 |     "title": "Explain Code ({{location}})",
 18 |     "icon": {
 19 |       "type": "codicon",
 20 |       "value": "book"
 21 |     }
 22 |   },
 23 |   "variables": [
 24 |     {
 25 |       "name": "selectedText",
 26 |       "time": "conversation-start",
 27 |       "type": "selected-text",
 28 |       "constraints": [{ "type": "text-length", "min": 1 }]
 29 |     },
 30 |     {
 31 |       "name": "location",
 32 |       "time": "conversation-start",
 33 |       "type": "selected-location-text"
 34 |     },
 35 |     {
 36 |       "name": "firstMessage",
 37 |       "time": "message",
 38 |       "type": "message",
 39 |       "property": "content",
 40 |       "index": 0
 41 |     },
 42 |     {
 43 |       "name": "lastMessage",
 44 |       "time": "message",
 45 |       "type": "message",
 46 |       "property": "content",
 47 |       "index": -1
 48 |     }
 49 |   ],
 50 |   "initialMessage": {
 51 |     "placeholder": "Generating explanation",
 52 |     "maxTokens": 512
 53 |   },
 54 |   "response": {
 55 |     "maxTokens": 1024,
 56 |     "stop": ["Bot:", "Developer:"]
 57 |   }
 58 | }
 59 | ```
 60 | 
 61 | ### Initial Message Prompt
 62 | 
 63 | ```template-initial-message
 64 | ## Instructions
 65 | Summarize the code below (emphasizing its key functionality).
 66 | 
 67 | ## Selected Code
 68 | \`\`\`
 69 | {{selectedText}}
 70 | \`\`\`
 71 | 
 72 | ## Task
 73 | Summarize the code at a high level (including goal and purpose) with an emphasis on its key functionality.
 74 | 
 75 | ## Response
 76 | 
 77 | ```
 78 | 
 79 | ### Response Prompt
 80 | 
 81 | ```template-response
 82 | ## Instructions
 83 | Continue the conversation below.
 84 | Pay special attention to the current developer request.
 85 | 
 86 | ## Current Request
 87 | Developer: {{lastMessage}}
 88 | 
 89 | {{#if selectedText}}
 90 | ## Selected Code
 91 | \`\`\`
 92 | {{selectedText}}
 93 | \`\`\`
 94 | {{/if}}
 95 | 
 96 | ## Code Summary
 97 | {{firstMessage}}
 98 | 
 99 | ## Conversation
100 | {{#each messages}}
101 | {{#if (neq @index 0)}}
102 | {{#if (eq author "bot")}}
103 | Bot: {{content}}
104 | {{else}}
105 | Developer: {{content}}
106 | {{/if}}
107 | {{/if}}
108 | {{/each}}
109 | 
110 | ## Task
111 | Write a response that continues the conversation.
112 | Stay focused on current developer request.
113 | Consider the possibility that there might not be a solution.
114 | Ask for clarification if the message does not make sense or more input is needed.
115 | Use the style of a documentation article.
116 | Omit any links.
117 | Include code snippets (using Markdown) and examples where appropriate.
118 | 
119 | ## Response
120 | Bot:
121 | ```
122 | 
--------------------------------------------------------------------------------
/template/task/find-bugs.rdt.md:
--------------------------------------------------------------------------------
  1 | # Find Bugs
  2 | 
  3 | Template to find bugs in the selected code.
  4 | 
  5 | ## Template
  6 | 
  7 | ### Configuration
  8 | 
  9 | ```json conversation-template
 10 | {
 11 |   "id": "find-bugs",
 12 |   "engineVersion": 0,
 13 |   "label": "Find bugs",
 14 |   "tags": ["debug", "code quality"],
 15 |   "description": "Find potential bugs in the selected code.",
 16 |   "header": {
 17 |     "title": "Find bugs ({{location}})",
 18 |     "icon": {
 19 |       "type": "codicon",
 20 |       "value": "bug"
 21 |     }
 22 |   },
 23 |   "variables": [
 24 |     {
 25 |       "name": "selectedText",
 26 |       "time": "conversation-start",
 27 |       "type": "selected-text",
 28 |       "constraints": [{ "type": "text-length", "min": 1 }]
 29 |     },
 30 |     {
 31 |       "name": "language",
 32 |       "time": "conversation-start",
 33 |       "type": "language",
 34 |       "constraints": [{ "type": "text-length", "min": 1 }]
 35 |     },
 36 |     {
 37 |       "name": "location",
 38 |       "time": "conversation-start",
 39 |       "type": "selected-location-text"
 40 |     },
 41 |     {
 42 |       "name": "firstMessage",
 43 |       "time": "message",
 44 |       "type": "message",
 45 |       "property": "content",
 46 |       "index": 0
 47 |     },
 48 |     {
 49 |       "name": "lastMessage",
 50 |       "time": "message",
 51 |       "type": "message",
 52 |       "property": "content",
 53 |       "index": -1
 54 |     }
 55 |   ],
 56 |   "initialMessage": {
 57 |     "placeholder": "Searching for bugs",
 58 |     "maxTokens": 1024
 59 |   },
 60 |   "response": {
 61 |     "maxTokens": 1024,
 62 |     "stop": ["Bot:", "Developer:"]
 63 |   }
 64 | }
 65 | ```
 66 | 
 67 | ### Initial Message Prompt
 68 | 
 69 | ```template-initial-message
 70 | ## Instructions
 71 | What could be wrong with the code below?
 72 | Only consider defects that would lead to incorrect behavior.
 73 | The programming language is {{language}}.
 74 | 
 75 | ## Selected Code
 76 | \`\`\`
 77 | {{selectedText}}
 78 | \`\`\`
 79 | 
 80 | ## Task
 81 | Describe what could be wrong with the code?
 82 | Only consider defects that would lead to incorrect behavior.
 83 | Provide potential fix suggestions where possible.
 84 | Consider that there might not be any problems with the code."
 85 | Include code snippets (using Markdown) and examples where appropriate.
 86 | 
 87 | ## Analysis
 88 | 
 89 | ```
 90 | 
 91 | ### Response Prompt
 92 | 
 93 | ```template-response
 94 | ## Instructions
 95 | Continue the conversation below.
 96 | Pay special attention to the current developer request.
 97 | The programming language is {{language}}.
 98 | 
 99 | ## Current Request
100 | Developer: {{lastMessage}}
101 | 
102 | {{#if selectedText}}
103 | ## Selected Code
104 | \`\`\`
105 | {{selectedText}}
106 | \`\`\`
107 | {{/if}}
108 | 
109 | ## Potential Bugs
110 | {{firstMessage}}
111 | 
112 | ## Conversation
113 | {{#each messages}}
114 | {{#if (neq @index 0)}}
115 | {{#if (eq author "bot")}}
116 | Bot: {{content}}
117 | {{else}}
118 | Developer: {{content}}
119 | {{/if}}
120 | {{/if}}
121 | {{/each}}
122 | 
123 | ## Task
124 | Write a response that continues the conversation.
125 | Stay focused on current developer request.
126 | Consider the possibility that there might not be a solution.
127 | Ask for clarification if the message does not make sense or more input is needed.
128 | Use the style of a documentation article.
129 | Omit any links.
130 | Include code snippets (using Markdown) and examples where appropriate.
131 | 
132 | ## Response
133 | Bot:
134 | ```
135 | 
--------------------------------------------------------------------------------
/template/task/generate-code.rdt.md:
--------------------------------------------------------------------------------
 1 | # Generate Code
 2 | 
 3 | Generate code using instructions.
 4 | 
 5 | ## Template
 6 | 
 7 | ### Configuration
 8 | 
 9 | ````json conversation-template
10 | {
11 |   "id": "generate-code",
12 |   "engineVersion": 0,
13 |   "label": "Generate Code",
14 |   "tags": ["generate"],
15 |   "description": "Generate code using instructions.",
16 |   "header": {
17 |     "title": "Generate Code",
18 |     "icon": {
19 |       "type": "codicon",
20 |       "value": "wand"
21 |     }
22 |   },
23 |   "chatInterface": "instruction-refinement",
24 |   "variables": [],
25 |   "response": {
26 |     "placeholder": "Generating code",
27 |     "maxTokens": 2048,
28 |     "stop": ["```"],
29 |     "completionHandler": {
30 |       "type": "update-temporary-editor",
31 |       "botMessage": "Generated code."
32 |     }
33 |   }
34 | }
35 | ````
36 | 
37 | ### Response Prompt
38 | 
39 | ```template-response
40 | ## Instructions
41 | Generate code for the following specification.
42 | 
43 | ## Specification
44 | {{#each messages}}
45 | {{#if (eq author "user")}}
46 | {{content}}
47 | {{/if}}
48 | {{/each}}
49 | 
50 | ## Instructions
51 | Generate code for the specification.
52 | 
53 | ## Code
54 | \`\`\`
55 | 
56 | ```
57 | 
--------------------------------------------------------------------------------
/template/task/generate-unit-test.rdt.md:
--------------------------------------------------------------------------------
  1 | # Generate Unit Test
  2 | 
  3 | Generate unit test cases for the selected code.
  4 | 
  5 | ## Template
  6 | 
  7 | ### Configuration
  8 | 
  9 | ````json conversation-template
 10 | {
 11 |   "id": "generate-unit-test",
 12 |   "engineVersion": 0,
 13 |   "label": "Generate Unit Test",
 14 |   "tags": ["generate", "test"],
 15 |   "description": "Generate a unit test for the selected code.",
 16 |   "header": {
 17 |     "title": "Generate Unit Test ({{location}})",
 18 |     "icon": {
 19 |       "type": "codicon",
 20 |       "value": "beaker"
 21 |     }
 22 |   },
 23 |   "chatInterface": "instruction-refinement",
 24 |   "variables": [
 25 |     {
 26 |       "name": "selectedText",
 27 |       "time": "conversation-start",
 28 |       "type": "selected-text",
 29 |       "constraints": [{ "type": "text-length", "min": 1 }]
 30 |     },
 31 |     {
 32 |       "name": "language",
 33 |       "time": "conversation-start",
 34 |       "type": "language",
 35 |       "constraints": [{ "type": "text-length", "min": 1 }]
 36 |     },
 37 |     {
 38 |       "name": "location",
 39 |       "time": "conversation-start",
 40 |       "type": "selected-location-text"
 41 |     },
 42 |     {
 43 |       "name": "lastMessage",
 44 |       "time": "message",
 45 |       "type": "message",
 46 |       "property": "content",
 47 |       "index": -1
 48 |     }
 49 |   ],
 50 |   "initialMessage": {
 51 |     "placeholder": "Generating Test",
 52 |     "maxTokens": 1536,
 53 |     "stop": ["```"],
 54 |     "completionHandler": {
 55 |       "type": "update-temporary-editor",
 56 |       "botMessage": "Generated unit test.",
 57 |       "language": "{{language}}"
 58 |     }
 59 |   },
 60 |   "response": {
 61 |     "placeholder": "Updating Test",
 62 |     "maxTokens": 1536,
 63 |     "stop": ["```"],
 64 |     "completionHandler": {
 65 |       "type": "update-temporary-editor",
 66 |       "botMessage": "Updated unit test.",
 67 |       "language": "{{language}}"
 68 |     }
 69 |   }
 70 | }
 71 | ````
 72 | 
 73 | ### Initial Message Prompt
 74 | 
 75 | ```template-initial-message
 76 | ## Instructions
 77 | Write a unit test for the code below.
 78 | 
 79 | ## Selected Code
 80 | \`\`\`
 81 | {{selectedText}}
 82 | \`\`\`
 83 | 
 84 | ## Task
 85 | Write a unit test that contains test cases for the happy path and for all edge cases.
 86 | The programming language is {{language}}.
 87 | 
 88 | ## Unit Test
 89 | \`\`\`
 90 | 
 91 | ```
 92 | 
 93 | ### Response Prompt
 94 | 
 95 | ```template-response
 96 | ## Instructions
 97 | Rewrite the code below as follows: "{{lastMessage}}"
 98 | 
 99 | ## Code
100 | \`\`\`
101 | {{temporaryEditorContent}}
102 | \`\`\`
103 | 
104 | ## Task
105 | Rewrite the code below as follows: "{{lastMessage}}"
106 | 
107 | ## Answer
108 | \`\`\`
109 | 
110 | ```
111 | 
--------------------------------------------------------------------------------
/template/task/improve-readability.rdt.md:
--------------------------------------------------------------------------------
  1 | # Improve Readability
  2 | 
  3 | The improve readability analysis suggests ways to make the selected code easier to read.
  4 | 
  5 | ## Template
  6 | 
  7 | ### Configuration
  8 | 
  9 | ```json conversation-template
 10 | {
 11 |   "id": "improve-readability",
 12 |   "engineVersion": 0,
 13 |   "label": "Improve Readability",
 14 |   "description": "Improve the readability of the selected code.",
 15 |   "tags": ["code quality"],
 16 |   "header": {
 17 |     "title": "Improve readability ({{location}})",
 18 |     "icon": {
 19 |       "type": "codicon",
 20 |       "value": "symbol-color"
 21 |     }
 22 |   },
 23 |   "variables": [
 24 |     {
 25 |       "name": "selectedText",
 26 |       "time": "conversation-start",
 27 |       "type": "selected-text",
 28 |       "constraints": [{ "type": "text-length", "min": 1 }]
 29 |     },
 30 |     {
 31 |       "name": "language",
 32 |       "time": "conversation-start",
 33 |       "type": "language",
 34 |       "constraints": [{ "type": "text-length", "min": 1 }]
 35 |     },
 36 |     {
 37 |       "name": "location",
 38 |       "time": "conversation-start",
 39 |       "type": "selected-location-text"
 40 |     },
 41 |     {
 42 |       "name": "firstMessage",
 43 |       "time": "message",
 44 |       "type": "message",
 45 |       "property": "content",
 46 |       "index": 0
 47 |     },
 48 |     {
 49 |       "name": "lastMessage",
 50 |       "time": "message",
 51 |       "type": "message",
 52 |       "property": "content",
 53 |       "index": -1
 54 |     }
 55 |   ],
 56 |   "chatInterface": "instruction-refinement",
 57 |   "initialMessage": {
 58 |     "placeholder": "Looking for readability improvements",
 59 |     "maxTokens": 1024
 60 |   },
 61 |   "response": {
 62 |     "maxTokens": 1024,
 63 |     "stop": ["Bot:", "Developer:"]
 64 |   }
 65 | }
 66 | ```
 67 | 
 68 | ### Initial Message Prompt
 69 | 
 70 | ```template-initial-message
 71 | ## Instructions
 72 | How could the readability of the code below be improved?
 73 | The programming language is {{language}}.
 74 | Consider overall readability and idiomatic constructs.
 75 | 
 76 | ## Selected Code
 77 | \`\`\`
 78 | {{selectedText}}
 79 | \`\`\`
 80 | 
 81 | ## Task
 82 | How could the readability of the code be improved?
 83 | The programming language is {{language}}.
 84 | Consider overall readability and idiomatic constructs.
 85 | Provide potential improvements suggestions where possible.
 86 | Consider that the code might be perfect and no improvements are possible.
 87 | Include code snippets (using Markdown) and examples where appropriate.
 88 | The code snippets must contain valid {{language}} code.
 89 | 
 90 | ## Readability Improvements
 91 | 
 92 | ```
 93 | 
 94 | ### Response Prompt
 95 | 
 96 | ```template-response
 97 | ## Instructions
 98 | Continue the conversation below.
 99 | Pay special attention to the current developer request.
100 | The programming language is {{language}}.
101 | 
102 | ## Current Request
103 | Developer: {{lastMessage}}
104 | 
105 | {{#if selectedText}}
106 | ## Selected Code
107 | \`\`\`
108 | {{selectedText}}
109 | \`\`\`
110 | {{/if}}
111 | 
112 | ## Conversation
113 | {{#each messages}}
114 | {{#if (eq author "bot")}}
115 | Bot: {{content}}
116 | {{else}}
117 | Developer: {{content}}
118 | {{/if}}
119 | {{/each}}
120 | 
121 | ## Task
122 | Write a response that continues the conversation.
123 | Stay focused on current developer request.
124 | Consider the possibility that there might not be a solution.
125 | Ask for clarification if the message does not make sense or more input is needed.
126 | Use the style of a documentation article.
127 | Omit any links.
128 | Include code snippets (using Markdown) and examples where appropriate.
129 | The code snippets must contain valid {{language}} code.
130 | 
131 | ## Response
132 | Bot:
133 | ```
134 | 
--------------------------------------------------------------------------------