* 🎨 refactor out react context * 🎨 refactor local storage * 🎨 refactor IdeMessenger * 🔥 removing unused files * 🚚 move scripts * ✅ setup VSCode integration testing * 🎨 fix test-related stuff * 🚧 testing * 🎨 tweak terminal cmd+L * 🧑💻 install biome in core * 🎨 run biome check on core * 🎨 run biome check in vscode * 🎨 run biome check in binary * 🧑💻 global biome config * 🎨 run biome check on core * 🎨 run biome check in vscode * 🎨 fix a few biome warnings * 🚧 WIP on protocols * 🚧 progress, organizing, about to remove webviewCore protocol * 🚧 now running * 🚧 move indexing code to core * 🚧 WIP on JetBrains indexing implementation * 🎨 finish listDir * 🚧 gui fixes * 🏷️ update IMessenger.on return type * 🐛 fix jetbrains types + IDE detection * 🧑💻 set up debugging for binary with TcpMessenger * 👷 fix prepackage.js * 🧑💻 turn off debug mode for intellij * 🐛 merge fixes * 🐛 fixes after refactor * 🐛 merge fixes * 💄 increase font size in JB * 🔀 merge changes * 🩹 small fixes * 🐛 fix jetbrains build * 🩹 more jetbrains fixes * 🎨 jetbrains improvements * 🐛 fix lancedb prob in jetbrains build * 👷 update jetbrains build process * ✨ intellij problems context provider * 👷 add script utils file * 💚 fix jetbrains build regression * 🎨 dynamic import transformers.js * 🩹 small jetbrains updates * ✨ folder context provider in jetbrains * 🎨 many more jetbrains improvements * 🔀 merge fixes * ⚡️ small improvements * 🎨 tell users transformers.js not supported * 🎨 trial updates * 📝 update jetbrains readmej * ⚡️ only use smaller context for local autocomplete models * ⚡️ improve bracket filter * ✨ global .continue/.prompts folder * 💄 improved model setup process * 🥅 display VSCode req errs
123 lines
3.1 KiB
TypeScript
123 lines
3.1 KiB
TypeScript
import * as dotenv from "dotenv";
|
|
import fetch from "node-fetch";
|
|
import { ContinueSDK } from "../index.js";
|
|
import EditSlashCommand, { getPromptParts } from "../commands/slash/edit.js";
|
|
import { contextItemToRangeInFileWithContents } from "../commands/util.js";
|
|
import FreeTrial from "../llm/llms/FreeTrial.js";
|
|
import Ollama from "../llm/llms/Ollama.js";
|
|
import { dedentAndGetCommonWhitespace } from "../util/index.js";
|
|
import FileSystemIde from "../util/filesystem.js";
|
|
|
|
jest.setTimeout(100_000);
|
|
|
|
dotenv.config();
|
|
|
|
const TEST_CONTEXT_ITEM = {
|
|
name: "editme.py (1-2)",
|
|
description: "/Users/natesesti/Desktop/continue/core/llm/test/editme.py",
|
|
content: "def average(nums: list) -> float:\n pass\n",
|
|
id: {
|
|
providerTitle: "code",
|
|
itemId: "/Users/natesesti/Desktop/continue/core/llm/test/editme.py",
|
|
},
|
|
editing: true,
|
|
};
|
|
|
|
const f1 = `\
|
|
def maximum(nums: list) -> float:
|
|
return max(nums)
|
|
`;
|
|
|
|
const f2 = `\
|
|
def total(nums: list) -> float:
|
|
s = sum(nums)
|
|
return s
|
|
`;
|
|
|
|
const f3 = `\
|
|
def average(nums: list) -> float:
|
|
return sum(nums) / len(nums)
|
|
`;
|
|
|
|
const fullFile = `${f1}\n${f2}\n${f3}\n`;
|
|
|
|
const TEST_CONTEXT_ITEM2 = {
|
|
name: "editme2.py (4-7)",
|
|
description: "/Users/natesesti/Desktop/continue/core/llm/test/editme2.py",
|
|
content: f2,
|
|
id: {
|
|
providerTitle: "code",
|
|
itemId: "/Users/natesesti/Desktop/continue/core/llm/test/editme2.py",
|
|
},
|
|
editing: true,
|
|
};
|
|
|
|
describe("/edit slash command", () => {
|
|
test.only("doesn't break", async () => {
|
|
const command = EditSlashCommand;
|
|
const sdk: ContinueSDK = {
|
|
ide: new FileSystemIde(),
|
|
// llm: new FreeTrial({ model: "gpt-3.5-turbo" }),
|
|
llm: new Ollama({ model: "codellama-7b" }),
|
|
addContextItem: (item: any) => {},
|
|
history: [],
|
|
input: "implement this function",
|
|
contextItems: [TEST_CONTEXT_ITEM],
|
|
selectedCode: [],
|
|
config: {} as any,
|
|
fetch,
|
|
};
|
|
|
|
let total = "";
|
|
for await (const update of command.run(sdk)) {
|
|
if (update === undefined) {continue;}
|
|
total += update;
|
|
}
|
|
console.log(total);
|
|
});
|
|
|
|
test.skip("dedentAndGetCommonWhitespace", () => {
|
|
// TODO
|
|
const [dedented, whitespace] = dedentAndGetCommonWhitespace(
|
|
`\
|
|
...
|
|
...
|
|
...
|
|
..
|
|
. .`,
|
|
);
|
|
|
|
expect(dedented).toEqual(`\
|
|
...
|
|
...
|
|
...
|
|
..
|
|
. .`);
|
|
expect(whitespace).toEqual(" ");
|
|
|
|
const [dedented2, whitespace2] = dedentAndGetCommonWhitespace("");
|
|
expect(dedented2).toEqual("");
|
|
expect(whitespace2).toEqual("");
|
|
|
|
const [dedented3, whitespace3] = dedentAndGetCommonWhitespace(" \n\n ");
|
|
expect(dedented3).toEqual(" \n\n ");
|
|
expect(whitespace3).toEqual("");
|
|
});
|
|
|
|
test.skip("getPromptParts", async () => {
|
|
// TODO
|
|
const { filePrefix, fileSuffix, contents, maxTokens } =
|
|
await getPromptParts(
|
|
contextItemToRangeInFileWithContents(TEST_CONTEXT_ITEM2),
|
|
fullFile,
|
|
new FreeTrial({ model: "gpt-3.5-turbo" }),
|
|
"implement this function",
|
|
1200,
|
|
);
|
|
|
|
expect(filePrefix).toEqual(`${f1}`);
|
|
expect(`${fileSuffix}\n`).toEqual(`\n${f3}`);
|
|
expect(contents).toEqual(f2);
|
|
expect(maxTokens).toEqual(2048);
|
|
});
|
|
});
|