From 646b19c4bfcef74400cc9a1506ed694ca2fbf2d5 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 24 Apr 2024 14:52:04 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20improve=20onboarding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config/default.ts | 94 ++++++++++--------- core/config/load.ts | 19 ++++ core/llm/llms/FreeTrial.ts | 4 +- docs/static/schemas/config.json | 23 +++++ .../src/main/resources/config_schema.json | 23 +++++ extensions/vscode/continue_rc_schema.json | 23 +++++ extensions/vscode/src/activation/activate.ts | 48 ++-------- extensions/vscode/src/util/vscode.ts | 9 +- extensions/vscode/src/webviewProtocol.ts | 4 +- gui/src/pages/help.tsx | 2 +- gui/src/pages/onboarding/onboarding.tsx | 6 +- 11 files changed, 157 insertions(+), 98 deletions(-) diff --git a/core/config/default.ts b/core/config/default.ts index eec8675e9..309e96267 100644 --- a/core/config/default.ts +++ b/core/config/default.ts @@ -1,4 +1,4 @@ -import { SerializedContinueConfig } from ".."; +import { ContextProviderWithParams, SerializedContinueConfig } from ".."; export const defaultConfig: SerializedContinueConfig = { models: [ @@ -28,24 +28,6 @@ export const defaultConfig: SerializedContinueConfig = { model: "mistral-8x7b", }, ], - slashCommands: [ - { - name: "edit", - description: "Edit selected code", - }, - { - name: "comment", - description: "Write comments for the selected code", - }, - { - name: "share", - description: "Export the current chat session to markdown", - }, - { - name: "cmd", - description: "Generate a shell command", - }, - ], customCommands: [ { name: "test", @@ -54,16 +36,6 @@ export const defaultConfig: SerializedContinueConfig = { description: "Write unit tests for highlighted code", }, ], - contextProviders: [ - { name: "code", params: {} }, - { name: "docs", params: {} }, - { name: "diff", params: {} }, - { name: "open", params: {} }, - { name: "terminal", params: {} }, - { name: "problems", params: {} }, - { name: "folder", params: {} }, - { name: "codebase", params: {} }, - ], tabAutocompleteModel: { title: "Starcoder2 3b", provider: "ollama", @@ -99,20 +71,6 @@ export const defaultConfigJetBrains: SerializedContinueConfig = { model: "mistral-8x7b", }, ], - slashCommands: [ - { - name: "edit", - description: "Edit selected code", - }, - { - name: "comment", - description: "Write comments for the selected code", - }, - { - name: "share", - description: "Export the current chat session to markdown", - }, - ], customCommands: [ { name: "test", @@ -121,10 +79,58 @@ export const defaultConfigJetBrains: SerializedContinueConfig = { description: "Write unit tests for highlighted code", }, ], - contextProviders: [{ name: "open", params: {} }], tabAutocompleteModel: { title: "Starcoder2 3b", provider: "ollama", model: "starcoder2:3b", }, }; + +export const defaultSlashCommandsVscode = [ + { + name: "edit", + description: "Edit selected code", + }, + { + name: "comment", + description: "Write comments for the selected code", + }, + { + name: "share", + description: "Export the current chat session to markdown", + }, + { + name: "cmd", + description: "Generate a shell command", + }, +]; + +export const defaultSlashCommandsJetBrains = [ + { + name: "edit", + description: "Edit selected code", + }, + { + name: "comment", + description: "Write comments for the selected code", + }, + { + name: "share", + description: "Export the current chat session to markdown", + }, +]; + +export const defaultContextProvidersVsCode: ContextProviderWithParams[] = [ + { name: "code", params: {} }, + { name: "docs", params: {} }, + { name: "diff", params: {} }, + { name: "open", params: {} }, + { name: "terminal", params: {} }, + { name: "problems", params: {} }, + { name: "folder", params: {} }, + { name: "codebase", params: {} }, +]; + +export const defaultContextProvidersJetBrains: ContextProviderWithParams[] = [ + { name: "open", params: {} }, +]; diff --git a/core/config/load.ts b/core/config/load.ts index 789ca2495..b8f67622b 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -43,6 +43,12 @@ import { getContinueDotEnv, migrate, } from "../util/paths"; +import { + defaultContextProvidersJetBrains, + defaultContextProvidersVsCode, + defaultSlashCommandsJetBrains, + defaultSlashCommandsVscode, +} from "./default"; const { execSync } = require("child_process"); function resolveSerializedConfig(filepath: string): SerializedContinueConfig { @@ -139,6 +145,16 @@ function loadSerializedConfig( ); } + // Set defaults if undefined (this lets us keep config.json uncluttered for new users) + config.contextProviders ??= + ideType === "vscode" + ? defaultContextProvidersVsCode + : defaultContextProvidersJetBrains; + config.slashCommands ??= + ideType === "vscode" + ? defaultSlashCommandsVscode + : defaultSlashCommandsJetBrains; + return config; } @@ -182,6 +198,7 @@ async function intermediateToFinalConfig( config: Config, readFile: (filepath: string) => Promise, ): Promise { + // Auto-detect models const models: BaseLLM[] = []; for (const desc of config.models) { if (isModelDescription(desc)) { @@ -244,6 +261,7 @@ async function intermediateToFinalConfig( } } + // Tab autocomplete model let autocompleteLlm: BaseLLM | undefined = undefined; if (config.tabAutocompleteModel) { if (isModelDescription(config.tabAutocompleteModel)) { @@ -258,6 +276,7 @@ async function intermediateToFinalConfig( } } + // Context providers const contextProviders: IContextProvider[] = [new FileContextProvider({})]; for (const provider of config.contextProviders || []) { if (isContextProviderWithParams(provider)) { diff --git a/core/llm/llms/FreeTrial.ts b/core/llm/llms/FreeTrial.ts index bd2cb51d1..ea542f375 100644 --- a/core/llm/llms/FreeTrial.ts +++ b/core/llm/llms/FreeTrial.ts @@ -94,10 +94,8 @@ class FreeTrial extends BaseLLM { async listModels(): Promise { return [ "gpt-3.5-turbo", - "gpt-4", - "gemini-1.5-pro-latest", "gpt-4-turbo", - "codellama-70b", + "gemini-1.5-pro-latest", "claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-3-haiku-20240307", diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 52e538c14..372af5229 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1127,6 +1127,29 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": [ + "share" + ] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "outputDir": { + "type": "string", + "markdownDescription": "If outputDir is set to `.` or begins with `./` or `.\\`, file will be saved to the current workspace or a subdirectory thereof, respectively. `~` can similarly be used to specify the user's home directory." + } + } + } + } + } } ], "required": ["name", "description"] diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 52e538c14..372af5229 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1127,6 +1127,29 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": [ + "share" + ] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "outputDir": { + "type": "string", + "markdownDescription": "If outputDir is set to `.` or begins with `./` or `.\\`, file will be saved to the current workspace or a subdirectory thereof, respectively. `~` can similarly be used to specify the user's home directory." + } + } + } + } + } } ], "required": ["name", "description"] diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index d1a90a6a7..9f986463d 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1244,6 +1244,29 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": [ + "share" + ] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "outputDir": { + "type": "string", + "markdownDescription": "If outputDir is set to `.` or begins with `./` or `.\\`, file will be saved to the current workspace or a subdirectory thereof, respectively. `~` can similarly be used to specify the user's home directory." + } + } + } + } + } } ], "required": [ diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts index 5af72bacb..53fff620b 100644 --- a/extensions/vscode/src/activation/activate.ts +++ b/extensions/vscode/src/activation/activate.ts @@ -6,40 +6,9 @@ import { VsCodeExtension } from "../extension/vscodeExtension"; import registerQuickFixProvider from "../lang-server/codeActions"; import { getExtensionVersion } from "../util/util"; import { getExtensionUri } from "../util/vscode"; +import { showTutorial } from "../webviewProtocol"; import { setupInlineTips } from "./inlineTips"; -function showRefactorMigrationMessage( - extensionContext: vscode.ExtensionContext, -) { - // Only if the vscode setting continue.manuallyRunningSserver is true - const manuallyRunningServer = - vscode.workspace - .getConfiguration("continue") - .get("manuallyRunningServer") || false; - if ( - manuallyRunningServer && - extensionContext?.globalState.get( - "continue.showRefactorMigrationMessage", - ) !== false - ) { - vscode.window - .showInformationMessage( - "The Continue server protocol was recently updated in a way that requires the latest server version to work properly. Since you are manually running the server, please be sure to upgrade with `pip install --upgrade continuedev`.", - "Got it", - "Don't show again", - ) - .then((selection) => { - if (selection === "Don't show again") { - // Get the global state - extensionContext?.globalState.update( - "continue.showRefactorMigrationMessage", - false, - ); - } - }); - } -} - export async function activateExtension(context: vscode.ExtensionContext) { // Add necessary files getTsConfigPath(); @@ -47,18 +16,15 @@ export async function activateExtension(context: vscode.ExtensionContext) { // Register commands and providers registerQuickFixProvider(); setupInlineTips(context); - showRefactorMigrationMessage(context); const vscodeExtension = new VsCodeExtension(context); - migrate("showWelcome_1", () => { - vscode.commands.executeCommand( - "markdown.showPreview", - vscode.Uri.file( - path.join(getExtensionUri().fsPath, "media", "welcome.md"), - ), - ); - }); + showTutorial(); + vscode.commands.executeCommand( + "markdown.showPreview", + vscode.Uri.file(path.join(getExtensionUri().fsPath, "media", "welcome.md")), + ); + migrate("showWelcome_1", () => {}); // Load Continue configuration if (!context.globalState.get("hasBeenInstalled")) { diff --git a/extensions/vscode/src/util/vscode.ts b/extensions/vscode/src/util/vscode.ts index c385deac0..321478eba 100644 --- a/extensions/vscode/src/util/vscode.ts +++ b/extensions/vscode/src/util/vscode.ts @@ -73,6 +73,7 @@ export function openEditorAndRevealRange( editorFilename: string, range?: vscode.Range, viewColumn?: vscode.ViewColumn, + preview?: boolean, ): Promise { return new Promise((resolve, _) => { if (editorFilename.startsWith("~")) { @@ -93,10 +94,10 @@ export function openEditorAndRevealRange( } showTextDocumentInProcess = true; vscode.window - .showTextDocument( - doc, - getViewColumnOfFile(editorFilename) || viewColumn, - ) + .showTextDocument(doc, { + viewColumn: getViewColumnOfFile(editorFilename) || viewColumn, + preview, + }) .then((editor) => { if (range) { editor.revealRange(range); diff --git a/extensions/vscode/src/webviewProtocol.ts b/extensions/vscode/src/webviewProtocol.ts index a87123836..f31ac7a7c 100644 --- a/extensions/vscode/src/webviewProtocol.ts +++ b/extensions/vscode/src/webviewProtocol.ts @@ -26,7 +26,7 @@ import * as vscode from "vscode"; import { VerticalPerLineDiffManager } from "./diff/verticalPerLine/manager"; import { getExtensionUri } from "./util/vscode"; -async function showTutorial() { +export async function showTutorial() { const tutorialPath = path.join( getExtensionUri().fsPath, "continue_tutorial.py", @@ -41,7 +41,7 @@ async function showTutorial() { const doc = await vscode.workspace.openTextDocument( vscode.Uri.file(tutorialPath), ); - await vscode.window.showTextDocument(doc); + await vscode.window.showTextDocument(doc, { preview: false }); } export class VsCodeWebviewProtocol { diff --git a/gui/src/pages/help.tsx b/gui/src/pages/help.tsx index e12f3f099..d205ac840 100644 --- a/gui/src/pages/help.tsx +++ b/gui/src/pages/help.tsx @@ -75,7 +75,7 @@ function HelpPage() { { postToIde("showTutorial", undefined); - // navigate("/onboarding"); + navigate("/onboarding"); }} > Open tutorial diff --git a/gui/src/pages/onboarding/onboarding.tsx b/gui/src/pages/onboarding/onboarding.tsx index 80336a922..9d0319cb0 100644 --- a/gui/src/pages/onboarding/onboarding.tsx +++ b/gui/src/pages/onboarding/onboarding.tsx @@ -33,9 +33,9 @@ function Onboarding() { >

✨ Cloud models

- This is the best experience. Use the best available commercial models - to index code and answer questions. Code is still only ever stored - locally. + This is the best experience. Continue will use the strongest available + commercial models to index code and answer questions. Code is only + ever stored locally.

{selected === 0 && (