Skip to content

Commit 780611d

Browse files
author
Calvinn Ng
committed
Re-merge uncommitted files
1 parent 8fedd44 commit 780611d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4973
-5520
lines changed

core/autocomplete/ast.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export async function getTreePathAtCursor(
4747

4848
return path;
4949
}
50+
}
5051

5152
export async function getScopeAroundRange(
5253
range: RangeInFileWithContents,

core/config/default.ts

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
1-
import { SerializedContinueConfig } from "..";
1+
import {
2+
ContextProviderWithParams,
3+
ModelDescription,
4+
SerializedContinueConfig,
5+
SlashCommandDescription,
6+
} from "../index.js";
7+
8+
export const FREE_TRIAL_MODELS: ModelDescription[] = [
9+
{
10+
title: "GPT-4o (Free Trial)",
11+
provider: "free-trial",
12+
model: "gpt-4o",
13+
systemMessage:
14+
"You are an expert software developer. You give helpful and concise responses.",
15+
},
16+
{
17+
title: "Llama3 70b (Free Trial)",
18+
provider: "free-trial",
19+
model: "llama3-70b",
20+
systemMessage:
21+
"You are an expert software developer. You give helpful and concise responses. Whenever you write a code block you include the language after the opening ticks.",
22+
},
23+
{
24+
title: "Codestral (Free Trial)",
25+
provider: "free-trial",
26+
model: "codestral",
27+
},
28+
{
29+
title: "Claude 3 Sonnet (Free Trial)",
30+
provider: "free-trial",
31+
model: "claude-3-sonnet-20240229",
32+
},
33+
];
234

335
export const defaultConfig: SerializedContinueConfig = {
436
"models": [
@@ -66,7 +98,7 @@ export const defaultConfig: SerializedContinueConfig = {
6698
],
6799
"tabAutocompleteOptions": {
68100
"template": "<|fim▁begin|>{{{prefix}}}<|fim▁hole|>{{{suffix}}}<|fim▁end|>",
69-
"useSuffix": true,
101+
"useFileSuffix": true,
70102
"useCache": true,
71103
"multilineCompletions": "auto",
72104
"debounceDelay": 50,
@@ -202,7 +234,7 @@ export const defaultConfigJetBrains: SerializedContinueConfig = {
202234
],
203235
"tabAutocompleteOptions": {
204236
"template": "<|fim▁begin|>{{{prefix}}}<|fim▁hole|>{{{suffix}}}<|fim▁end|>",
205-
"useSuffix": true,
237+
"useFileSuffix": true,
206238
"useCache": true,
207239
"multilineCompletions": "auto",
208240
"debounceDelay": 50,
@@ -271,3 +303,61 @@ export const defaultConfigJetBrains: SerializedContinueConfig = {
271303
"provider": "transformers.js"
272304
}
273305
};
306+
307+
export const defaultSlashCommandsVscode: SlashCommandDescription[] = [
308+
{
309+
name: "edit",
310+
description: "Edit selected code",
311+
},
312+
{
313+
name: "comment",
314+
description: "Write comments for the selected code",
315+
},
316+
{
317+
name: "share",
318+
description: "Export the current chat session to markdown",
319+
},
320+
{
321+
name: "cmd",
322+
description: "Generate a shell command",
323+
},
324+
{
325+
name: "commit",
326+
description: "Generate a git commit message",
327+
},
328+
];
329+
330+
export const defaultSlashCommandsJetBrains = [
331+
{
332+
name: "edit",
333+
description: "Edit selected code",
334+
},
335+
{
336+
name: "comment",
337+
description: "Write comments for the selected code",
338+
},
339+
{
340+
name: "share",
341+
description: "Export the current chat session to markdown",
342+
},
343+
{
344+
name: "commit",
345+
description: "Generate a git commit message",
346+
},
347+
];
348+
349+
export const defaultContextProvidersVsCode: ContextProviderWithParams[] = [
350+
{ name: "code", params: {} },
351+
{ name: "docs", params: {} },
352+
{ name: "diff", params: {} },
353+
{ name: "terminal", params: {} },
354+
{ name: "problems", params: {} },
355+
{ name: "folder", params: {} },
356+
{ name: "codebase", params: {} },
357+
];
358+
359+
export const defaultContextProvidersJetBrains: ContextProviderWithParams[] = [
360+
{ name: "diff", params: {} },
361+
{ name: "folder", params: {} },
362+
{ name: "codebase", params: {} },
363+
];

core/config/load.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ function loadSerializedConfig(
128128
getConfigJsonPathForRemote(ideSettings.remoteConfigServerUrl),
129129
);
130130
config = mergeJson(config, remoteConfigJson, "overwrite", configMergeKeys);
131+
132+
if (config.tabAutocompleteOptions) {
133+
config.tabAutocompleteOptions.multilineCompletions = "never";
134+
} else {
135+
config.tabAutocompleteOptions = { multilineCompletions: "never" };
136+
}
137+
131138
} catch (e) {
132139
console.warn("Error loading remote config: ", e);
133140
}
@@ -229,6 +236,7 @@ async function intermediateToFinalConfig(
229236
): Promise<ContinueConfig> {
230237
// Auto-detect models
231238
let models: BaseLLM[] = [];
239+
232240
for (const desc of config.models) {
233241
if (isModelDescription(desc)) {
234242
const llm = await llmFromDescription(
@@ -327,7 +335,7 @@ async function intermediateToFinalConfig(
327335

328336
// Tab autocomplete model
329337
let tabAutocompleteModels: BaseLLM[] = [];
330-
if (config.tabAutocompleteModel) {
338+
if (config.tabAutocompleteModels) {
331339
tabAutocompleteModels = (
332340
await Promise.all(
333341
(Array.isArray(config.tabAutocompleteModel)

core/index.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Model } from "openai/resources";
2+
13
declare global {
24
interface Window {
35
ide?: "vscode";
@@ -853,6 +855,7 @@ export interface SerializedContinueConfig {
853855
env?: string[];
854856
allowAnonymousTelemetry?: boolean;
855857
models: ModelDescription[];
858+
commandModels: ModelDescription[];
856859
systemMessage?: string;
857860
completionOptions?: BaseCompletionOptions;
858861
requestOptions?: RequestOptions;
@@ -863,7 +866,7 @@ export interface SerializedContinueConfig {
863866
disableSessionTitles?: boolean;
864867
userToken?: string;
865868
embeddingsProvider?: EmbeddingsProviderDescription;
866-
tabAutocompleteModel?: ModelDescription | ModelDescription[];
869+
tabAutocompleteModels?: ModelDescription | ModelDescription[];
867870
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
868871
ui?: ContinueUIConfig;
869872
reranker?: RerankerDescription;

core/indexing/CodeSnippetsIndex.ts

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,10 @@
1-
<<<<<<< HEAD
2-
import fs from "fs";
3-
import path from "path";
4-
import {
5-
=======
61
import type {
7-
>>>>>>> v0.9.184-vscode
82
ChunkWithoutID,
93
ContextItem,
104
ContextSubmenuItem,
115
IDE,
126
IndexTag,
137
IndexingProgressUpdate,
14-
<<<<<<< HEAD
15-
} from "..";
16-
import { getBasename, getLastNPathParts } from "../util/index.js";
17-
import {
18-
getLanguageForFile,
19-
getParserForFile,
20-
supportedLanguages,
21-
} from "../util/treeSitter";
22-
import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex";
23-
import {
24-
CodebaseIndex,
25-
IndexResultType,
26-
MarkCompleteCallback,
27-
RefreshIndexResults,
28-
} from "./types";
29-
30-
export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
31-
=======
328
} from "../index.js";
339
import { getBasename, getLastNPathParts } from "../util/index.js";
3410
import {
@@ -46,7 +22,6 @@ import {
4622

4723
export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
4824
relativeExpectedTime: number = 1;
49-
>>>>>>> v0.9.184-vscode
5025
artifactId = "codeSnippets";
5126

5227
constructor(private readonly ide: IDE) {}
@@ -70,45 +45,16 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
7045
)`);
7146
}
7247

73-
<<<<<<< HEAD
74-
private getQuerySource(filepath: string) {
75-
const fullLangName = supportedLanguages[filepath.split(".").pop() ?? ""];
76-
const sourcePath = path.join(
77-
__dirname,
78-
"..",
79-
"tree-sitter",
80-
"code-snippet-queries",
81-
`tree-sitter-${fullLangName}-tags.scm`,
82-
);
83-
if (!fs.existsSync(sourcePath)) {
84-
return "";
85-
}
86-
return fs.readFileSync(sourcePath).toString();
87-
}
88-
89-
=======
90-
>>>>>>> v0.9.184-vscode
9148
async getSnippetsInFile(
9249
filepath: string,
9350
contents: string,
9451
): Promise<(ChunkWithoutID & { title: string })[]> {
95-
<<<<<<< HEAD
96-
const lang = await getLanguageForFile(filepath);
97-
if (!lang) {
98-
return [];
99-
}
100-
=======
101-
>>>>>>> v0.9.184-vscode
10252
const parser = await getParserForFile(filepath);
10353
if (!parser) {
10454
return [];
10555
}
10656
const ast = parser.parse(contents);
107-
<<<<<<< HEAD
108-
const query = lang?.query(this.getQuerySource(filepath));
109-
=======
11057
const query = await getQueryForFile(filepath, TSQueryType.CodeSnippets);
111-
>>>>>>> v0.9.184-vscode
11258
const matches = query?.matches(ast.rootNode);
11359

11460
return (
@@ -138,12 +84,6 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
13884

13985
for (let i = 0; i < results.compute.length; i++) {
14086
const compute = results.compute[i];
141-
<<<<<<< HEAD
142-
const snippets = await this.getSnippetsInFile(
143-
compute.path,
144-
await this.ide.readFile(compute.path),
145-
);
146-
=======
14787

14888
let snippets: (ChunkWithoutID & { title: string })[] = [];
14989
try {
@@ -154,16 +94,11 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
15494
} catch (e) {
15595
// If can't parse, assume malformatted code
15696
}
157-
>>>>>>> v0.9.184-vscode
15897

15998
// Add snippets to sqlite
16099
for (const snippet of snippets) {
161100
const { lastID } = await db.run(
162-
<<<<<<< HEAD
163-
`INSERT INTO code_snippets (path, cacheKey, content, title, startLine, endLine) VALUES (?, ?, ?, ?, ?, ?)`,
164-
=======
165101
"INSERT INTO code_snippets (path, cacheKey, content, title, startLine, endLine) VALUES (?, ?, ?, ?, ?, ?)",
166-
>>>>>>> v0.9.184-vscode
167102
[
168103
compute.path,
169104
compute.cacheKey,
@@ -175,21 +110,13 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
175110
);
176111

177112
await db.run(
178-
<<<<<<< HEAD
179-
`INSERT INTO code_snippets_tags (snippetId, tag) VALUES (?, ?)`,
180-
=======
181113
"INSERT INTO code_snippets_tags (snippetId, tag) VALUES (?, ?)",
182-
>>>>>>> v0.9.184-vscode
183114
[lastID, tagString],
184115
);
185116
}
186117

187118
yield {
188-
<<<<<<< HEAD
189-
desc: `Indexing ${compute.path}`,
190-
=======
191119
desc: `Indexing ${getBasename(compute.path)}`,
192-
>>>>>>> v0.9.184-vscode
193120
progress: i / results.compute.length,
194121
status: "indexing",
195122
};
@@ -199,39 +126,24 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
199126
for (let i = 0; i < results.del.length; i++) {
200127
const del = results.del[i];
201128
const deleted = await db.run(
202-
<<<<<<< HEAD
203-
`DELETE FROM code_snippets WHERE path = ? AND cacheKey = ?`,
204-
[del.path, del.cacheKey],
205-
);
206-
await db.run(`DELETE FROM code_snippets_tags WHERE snippetId = ?`, [
207-
=======
208129
"DELETE FROM code_snippets WHERE path = ? AND cacheKey = ?",
209130
[del.path, del.cacheKey],
210131
);
211132
await db.run("DELETE FROM code_snippets_tags WHERE snippetId = ?", [
212-
>>>>>>> v0.9.184-vscode
213133
deleted.lastID,
214134
]);
215135
markComplete([del], IndexResultType.Delete);
216136
}
217137

218138
for (let i = 0; i < results.addTag.length; i++) {
219139
const snippetsWithPath = await db.all(
220-
<<<<<<< HEAD
221-
`SELECT * FROM code_snippets WHERE cacheKey = ?`,
222-
=======
223140
"SELECT * FROM code_snippets WHERE cacheKey = ?",
224-
>>>>>>> v0.9.184-vscode
225141
[results.addTag[i].cacheKey],
226142
);
227143

228144
for (const snippet of snippetsWithPath) {
229145
await db.run(
230-
<<<<<<< HEAD
231-
`INSERT INTO code_snippets_tags (snippetId, tag) VALUES (?, ?)`,
232-
=======
233146
"INSERT INTO code_snippets_tags (snippetId, tag) VALUES (?, ?)",
234-
>>>>>>> v0.9.184-vscode
235147
[snippet.id, tagString],
236148
);
237149
}
@@ -258,11 +170,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
258170

259171
static async getForId(id: number): Promise<ContextItem> {
260172
const db = await SqliteDb.get();
261-
<<<<<<< HEAD
262-
const row = await db.get(`SELECT * FROM code_snippets WHERE id = ?`, [id]);
263-
=======
264173
const row = await db.get("SELECT * FROM code_snippets WHERE id = ?", [id]);
265-
>>>>>>> v0.9.184-vscode
266174

267175
return {
268176
name: row.title,

0 commit comments

Comments
 (0)