Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sestinj committed May 6, 2024
2 parents 4cd2340 + 190ea4f commit c8e03b6
Show file tree
Hide file tree
Showing 176 changed files with 4,264 additions and 16,238 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ body:
required: false
- label: I'm not able to find an [open issue](https://github.com/continuedev/continue/issues?q=is%3Aopen+is%3Aissue) that reports the same bug
required: false
- label: I've seen the [troubleshooting guide](https://continue.dev/docs/troubleshooting) on the Continue Docs
- label: I've seen the [troubleshooting guide](https://docs.continue.dev/troubleshooting) on the Continue Docs
required: false
- type: textarea
attributes:
Expand Down Expand Up @@ -58,5 +58,5 @@ body:
attributes:
label: Log output
description: |
Please refer to the [troubleshooting guide](https://continue.dev/docs/troubleshooting) in the Continue Docs for instructions on obtaining the logs. Copy either the relevant lines or the last 100 lines or so.
Please refer to the [troubleshooting guide](https://docs.continue.dev/troubleshooting) in the Continue Docs for instructions on obtaining the logs. Copy either the relevant lines or the last 100 lines or so.
render: Shell
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,6 @@ continue_server.build
continue_server.dist

Icon
Icon?
Icon?

.continue
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"tabWidth": 2,
"useTabs": false
"useTabs": false,
"trailingComma": "all"
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Continue is quickly adding features, and we'd love to hear which are the most im

## 📖 Updating / Improving Documentation

Continue is continuously improving, but a feature isn't complete until it is reflected in the documentation! If you see something out-of-date or missing, you can help by clicking "Edit this page" at the bottom of any page on [continue.dev/docs](https://continue.dev/docs).
Continue is continuously improving, but a feature isn't complete until it is reflected in the documentation! If you see something out-of-date or missing, you can help by clicking "Edit this page" at the bottom of any page on [docs.continue.dev](https://docs.continue.dev).

## 🧑‍💻 Contributing Code

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<div align="center">

**[Continue](https://continue.dev/docs) keeps developers in flow. Our open-source [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) and [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension) extensions enable you to easily create your own modular AI software development system that you can improve.**
**[Continue](https://docs.continue.dev) keeps developers in flow. Our open-source [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) and [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension) extensions enable you to easily create your own modular AI software development system that you can improve.**

</div>

Expand All @@ -17,7 +17,7 @@
<a target="_blank" href="https://opensource.org/licenses/Apache-2.0" style="background:none">
<img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" style="height: 22px;" />
</a>
<a target="_blank" href="https://continue.dev/docs" style="background:none">
<a target="_blank" href="https://docs.continue.dev" style="background:none">
<img src="https://img.shields.io/badge/continue_docs-%23BE1B55" style="height: 22px;" />
</a>
<a target="_blank" href="https://discord.gg/vapESyrFmJ" style="background:none">
Expand Down
5 changes: 4 additions & 1 deletion binary/pkgJson/win32-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"../../../core/node_modules/sqlite3/**/*",
"../../node_modules/@lancedb/vectordb-win32-x64-msvc/index.node",
"../../out/tree-sitter.wasm",
"../../out/tree-sitter-wasms/*"
"../../out/tree-sitter-wasms/*",
"../../node_modules/win-ca/lib/crypt32-ia32.node",
"../../node_modules/win-ca/lib/crypt32-x64.node",
"../../node_modules/win-ca/lib/roots.exe"
],
"targets": [
"node18-win-arm64"
Expand Down
5 changes: 4 additions & 1 deletion binary/pkgJson/win32-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"../../../core/node_modules/sqlite3/**/*",
"../../node_modules/@lancedb/vectordb-win32-x64-msvc/index.node",
"../../out/tree-sitter.wasm",
"../../out/tree-sitter-wasms/*"
"../../out/tree-sitter-wasms/*",
"../../node_modules/win-ca/lib/crypt32-ia32.node",
"../../node_modules/win-ca/lib/crypt32-x64.node",
"../../node_modules/win-ca/lib/roots.exe"
],
"targets": [
"node18-win-x64"
Expand Down
11 changes: 10 additions & 1 deletion binary/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { indexDocs } from "core/indexing/docs";
import TransformersJsEmbeddingsProvider from "core/indexing/embeddings/TransformersJsEmbeddingsProvider";
import { CodebaseIndexer, PauseToken } from "core/indexing/indexCodebase";
import { logDevData } from "core/util/devdata";
import { fetchwithRequestOptions } from "core/util/fetchWithOptions";
import historyManager from "core/util/history";
import { Message } from "core/util/messenger";
import { Telemetry } from "core/util/posthog";
Expand Down Expand Up @@ -138,7 +139,11 @@ export class Core {
const config = await this.config();
const items = config.contextProviders
?.find((provider) => provider.description.title === msg.data.title)
?.loadSubmenuItems({ ide: this.ide });
?.loadSubmenuItems({
ide: this.ide,
fetch: (url, init) =>
fetchwithRequestOptions(url, init, config.requestOptions),
});
return items || [];
});
on("context/getContextItems", async (msg) => {
Expand All @@ -160,6 +165,8 @@ export class Core {
ide,
selectedCode: msg.data.selectedCode,
reranker: config.reranker,
fetch: (url, init) =>
fetchwithRequestOptions(url, init, config.requestOptions),
});

Telemetry.capture("useContextProvider", {
Expand Down Expand Up @@ -278,6 +285,8 @@ export class Core {
},
selectedCode,
config,
fetch: (url, init) =>
fetchwithRequestOptions(url, init, config.requestOptions),
})) {
if (content) {
yield { content };
Expand Down
5 changes: 4 additions & 1 deletion binary/src/messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export class IpcMessenger {
constructor() {
const logger = (message: any, ...optionalParams: any[]) => {
const logFilePath = getCoreLogsPath();
const logMessage = `${message} ${optionalParams.join(" ")}\n`;
const timestamp = new Date().toISOString().split(".")[0];
const logMessage = `[${timestamp}] ${message} ${optionalParams.join(
" ",
)}\n`;
fs.appendFileSync(logFilePath, logMessage);
};
console.log = logger;
Expand Down
38 changes: 33 additions & 5 deletions core/autocomplete/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export interface AutocompleteInput {
recentlyEditedFiles: RangeInFileWithContents[];
recentlyEditedRanges: RangeInFileWithContents[];
clipboardText: string;
// Used for notebook files
manuallyPassFileContents?: string;
// Used for VS Code git commit input box
manuallyPassPrefix?: string;
}

export interface AutocompleteOutcome extends TabAutocompleteOptions {
Expand All @@ -57,13 +61,20 @@ const DOUBLE_NEWLINE = "\n\n";
const WINDOWS_DOUBLE_NEWLINE = "\r\n\r\n";
const SRC_DIRECTORY = "/src/";
// Starcoder2 tends to output artifacts starting with the letter "t"
const STARCODER2_T_ARTIFACTS = ["t.", "\nt"];
const STARCODER2_T_ARTIFACTS = ["t.", "\nt", "<file_sep>"];
const PYTHON_ENCODING = "#- coding: utf-8";
const CODE_BLOCK_END = "```";

const multilineStops = [DOUBLE_NEWLINE, WINDOWS_DOUBLE_NEWLINE];
const commonStops = [SRC_DIRECTORY, PYTHON_ENCODING, CODE_BLOCK_END];

// Errors that can be expected on occasion even during normal functioning should not be shown.
// Not worth disrupting the user to tell them that a single autocomplete request didn't go through
const ERRORS_TO_IGNORE = [
// From Ollama
"unexpected server status",
];

function formatExternalSnippet(
filepath: string,
snippet: string,
Expand Down Expand Up @@ -105,8 +116,11 @@ export async function getTabCompletion(
recentlyEditedFiles,
recentlyEditedRanges,
clipboardText,
manuallyPassFileContents,
manuallyPassPrefix,
} = input;
const fileContents = await ide.readFile(filepath);
const fileContents =
manuallyPassFileContents ?? (await ide.readFile(filepath));
const fileLines = fileContents.split("\n");

// Filter
Expand Down Expand Up @@ -137,7 +151,7 @@ export async function getTabCompletion(
) {
shownGptClaudeWarning = true;
throw new Error(
`Warning: ${llm.model} is not trained for tab-autocomplete, and will result in low-quality suggestions. See the docs to learn more about why: https://continue.dev/docs/walkthroughs/tab-autocomplete#i-want-better-completions-should-i-use-gpt-4`,
`Warning: ${llm.model} is not trained for tab-autocomplete, and will result in low-quality suggestions. See the docs to learn more about why: https://docs.continue.dev/walkthroughs/tab-autocomplete#i-want-better-completions-should-i-use-gpt-4`,
);
}

Expand Down Expand Up @@ -187,6 +201,12 @@ export async function getTabCompletion(
extrasSnippets,
);

// If prefix is manually passed
if (manuallyPassPrefix) {
prefix = manuallyPassPrefix;
suffix = "";
}

// Template prompt
const { template, completionOptions } = options.template
? { template: options.template, completionOptions: {} }
Expand Down Expand Up @@ -281,8 +301,16 @@ export async function getTabCompletion(
lineGenerator = streamWithNewLines(lineGenerator);

const finalGenerator = stopAtSimilarLine(lineGenerator, lineBelowCursor);
for await (const update of finalGenerator) {
completion += update;

try {
for await (const update of finalGenerator) {
completion += update;
}
} catch (e: any) {
if (ERRORS_TO_IGNORE.some((err) => e.includes(err))) {
return undefined;
}
throw e;
}

if (cancelled) {
Expand Down
5 changes: 4 additions & 1 deletion core/autocomplete/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export const Typescript = {

// Python
export const Python = {
stopWords: ["def", "class"],
// """"#" is for .ipynb files, where we add '"""' surrounding markdown blocks.
// This stops the model from trying to complete the start of a new markdown block
stopWords: ["def", "class", '"""#'],
comment: "#",
endOfLine: [],
};
Expand Down Expand Up @@ -211,6 +213,7 @@ export const LANGUAGES: { [extension: string]: AutocompleteLanguageInfo } = {
js: Typescript,
tsx: Typescript,
jsx: Typescript,
ipynb: Python,
py: Python,
pyi: Python,
java: Java,
Expand Down
12 changes: 11 additions & 1 deletion core/autocomplete/lineStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ export async function* stopAtLines(stream: LineStream): LineStream {
}
}

const LINES_TO_SKIP = ["</START EDITING HERE>"];

export async function* skipLines(stream: LineStream): LineStream {
for await (const line of stream) {
if (!LINES_TO_SKIP.some((skipAt) => line.startsWith(skipAt))) {
yield line;
}
}
}

function shouldRemoveLineBeforeStart(line: string): boolean {
return (
line.trimStart().startsWith("```") ||
Expand Down Expand Up @@ -129,7 +139,7 @@ export async function* filterCodeBlockLines(rawLines: LineStream): LineStream {
return;
}

if (line === "```") {
if (line.startsWith("```")) {
waitingToSeeIfLineIsLast = line;
} else {
yield line;
Expand Down
15 changes: 12 additions & 3 deletions core/autocomplete/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ const stableCodeFimTemplate: AutocompleteTemplate = {
};

const codegemmaFimTemplate: AutocompleteTemplate = {
template: "<|fim_prefix|>{{{prefix}}}<|fim_suffix|>{{{suffix}}}<|fim_middle|>",
template:
"<|fim_prefix|>{{{prefix}}}<|fim_suffix|>{{{suffix}}}<|fim_middle|>",
completionOptions: {
stop: ["<|fim_prefix|>", "<|fim_suffix|>", "<|fim_middle|>", "<|file_separator|>", "<end_of_turn>", "<eos>"],
stop: [
"<|fim_prefix|>",
"<|fim_suffix|>",
"<|fim_middle|>",
"<|file_separator|>",
"<end_of_turn>",
"<eos>",
],
},
};

Expand Down Expand Up @@ -106,7 +114,8 @@ export function getTemplateForModel(model: string): AutocompleteTemplate {
lowerCaseModel.includes("star-coder") ||
lowerCaseModel.includes("starchat") ||
lowerCaseModel.includes("octocoder") ||
lowerCaseModel.includes("stable")
lowerCaseModel.includes("stable") ||
lowerCaseModel.includes("codeqwen")
) {
return stableCodeFimTemplate;
}
Expand Down
10 changes: 8 additions & 2 deletions core/commands/slash/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "../../autocomplete/lineStream";
import { streamLines } from "../../diff/util";
import { stripImages } from "../../llm/countTokens";
import { dedentAndGetCommonWhitespace } from "../../util";
import { dedentAndGetCommonWhitespace, getMarkdownLanguageTagForFile } from "../../util";
import {
RangeInFileWithContents,
contextItemToRangeInFileWithContents,
Expand Down Expand Up @@ -226,7 +226,7 @@ const EditSlashCommand: SlashCommand = {
}

if (!contextItemToEdit) {
yield "Select (highlight and press `cmd+shift+L` (MacOS) / `ctrl+shift+L` (Windows)) the code that you want to edit first";
yield "Please highlight the code you want to edit, then press `cmd/ctrl+shift+L` to add it to chat";
return;
}

Expand Down Expand Up @@ -456,6 +456,12 @@ const EditSlashCommand: SlashCommand = {
userInput,
filePrefix: filePrefix,
fileSuffix: fileSuffix,

// Some built-in templates use these instead of the above
prefix: filePrefix,
suffix: fileSuffix,

language: getMarkdownLanguageTagForFile(rif.filepath),
systemMessage: llm.systemMessage ?? "",
// "contextItems": (await sdk.getContextItemChatMessages()).map(x => x.content || "").join("\n\n"),
},
Expand Down
2 changes: 1 addition & 1 deletion core/commands/slash/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { removeQuotesAndEscapes } from "../../util";
const HttpSlashCommand: SlashCommand = {
name: "http",
description: "Call an HTTP endpoint to serve response",
run: async function* ({ ide, llm, input, params }) {
run: async function* ({ ide, llm, input, params, fetch }) {
const url = params?.url;
if (!url) {
throw new Error("URL is not defined in params");
Expand Down
Loading

0 comments on commit c8e03b6

Please sign in to comment.