Merge branch 'main' of github.com:continuedev/continue
This commit is contained in:
commit
524c7bd433
12 changed files with 4834 additions and 279 deletions
|
|
@ -54,6 +54,12 @@ class RangeInFileWithContents(RangeInFile):
|
|||
@staticmethod
|
||||
def from_entire_file(filepath: str, content: str) -> "RangeInFileWithContents":
|
||||
lines = content.splitlines()
|
||||
if not lines:
|
||||
return RangeInFileWithContents(
|
||||
filepath=filepath,
|
||||
range=Range.from_shorthand(0, 0, 0, 0),
|
||||
contents=""
|
||||
)
|
||||
return RangeInFileWithContents(
|
||||
filepath=filepath,
|
||||
range=Range.from_shorthand(
|
||||
|
|
|
|||
|
|
@ -74,11 +74,6 @@ class AddFileStep(Step):
|
|||
|
||||
await sdk.ide.setFileOpen(os.path.join(sdk.ide.workspace_directory, self.filename))
|
||||
|
||||
open_files = await sdk.ide.getOpenFiles()
|
||||
if len(open_files) > 0:
|
||||
currently_open_file = (await sdk.ide.getOpenFiles())[0]
|
||||
await sdk.ide.setFileOpen(currently_open_file)
|
||||
|
||||
|
||||
class DeleteFileStep(Step):
|
||||
name: str = "Delete File"
|
||||
|
|
|
|||
|
|
@ -7,3 +7,7 @@ This is the Continue VS Code Extension. Its primary jobs are
|
|||
3. Run a Continue server in the background, which connects to both the IDE protocol and the React app. The server is launched in `src/activation/environmentSetup.ts` by calling Python code that lives in `scripts/` (unless extension settings define a server URL other than localhost:65432, in which case the extension will just connect to that).
|
||||
|
||||
4. Open Continue
|
||||
|
||||
# Notes
|
||||
|
||||
- We require vscode engine `^1.67.0` and use `@types/vscode` version `1.67.0` because this is the earliest version that doesn't break any of the APIs we are using. If you go back to `1.66.0`, then it will break `vscode.window.tabGroups`.
|
||||
|
|
|
|||
4
extension/jest.config.js
Normal file
4
extension/jest.config.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
testEnvironment: "node",
|
||||
preset: "ts-jest",
|
||||
};
|
||||
4915
extension/package-lock.json
generated
4915
extension/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -14,10 +14,10 @@
|
|||
"displayName": "Continue",
|
||||
"pricing": "Free",
|
||||
"description": "The open-source coding autopilot",
|
||||
"version": "0.0.104",
|
||||
"version": "0.0.105",
|
||||
"publisher": "Continue",
|
||||
"engines": {
|
||||
"vscode": "^1.60.0"
|
||||
"vscode": "^1.67.0"
|
||||
},
|
||||
"categories": [
|
||||
"Other",
|
||||
|
|
@ -204,6 +204,7 @@
|
|||
"pretest": "npm run compile && npm run lint",
|
||||
"lint": "eslint src --ext ts",
|
||||
"test": "node ./out/test/runTest.js",
|
||||
"jest": "jest --config ./jest.config.js",
|
||||
"package": "cp ./config/prod_config.json ./config/config.json && mkdir -p ./build && vsce package --out ./build && cp ./config/dev_config.json ./config/config.json",
|
||||
"full-package": "cd ../continuedev && poetry build && cp ./dist/continuedev-0.1.2-py3-none-any.whl ../extension/scripts/continuedev-0.1.2-py3-none-any.whl && cd ../extension && npm install && npm run typegen && npm run clientgen && cd react-app && npm install && npm run build && cd .. && npm run package",
|
||||
"install-extension": "code --install-extension ./build/continue-0.0.8.vsix",
|
||||
|
|
@ -213,12 +214,13 @@
|
|||
"devDependencies": {
|
||||
"@openapitools/openapi-generator-cli": "^2.5.2",
|
||||
"@types/glob": "^8.0.0",
|
||||
"@types/jest": "^29.5.2",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/node": "16.x",
|
||||
"@types/node-fetch": "^2.6.2",
|
||||
"@types/react-dom": "^18.2.4",
|
||||
"@types/styled-components": "^5.1.26",
|
||||
"@types/vscode": "1.60",
|
||||
"@types/vscode": "1.67",
|
||||
"@types/ws": "^8.5.4",
|
||||
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
||||
"@typescript-eslint/parser": "^5.45.0",
|
||||
|
|
@ -226,8 +228,10 @@
|
|||
"esbuild": "^0.17.19",
|
||||
"eslint": "^8.28.0",
|
||||
"glob": "^8.0.3",
|
||||
"jest": "^29.5.0",
|
||||
"json-schema-to-typescript": "^12.0.0",
|
||||
"mocha": "^10.1.0",
|
||||
"ts-jest": "^29.1.1",
|
||||
"typescript": "^4.9.3",
|
||||
"vsce": "^2.15.0"
|
||||
},
|
||||
|
|
@ -243,7 +247,7 @@
|
|||
"downshift": "^7.6.0",
|
||||
"fkill": "^8.1.0",
|
||||
"highlight.js": "^11.7.0",
|
||||
"posthog-js": "^1.63.3",
|
||||
"posthog-js": "^1.68.3",
|
||||
"react-markdown": "^8.0.7",
|
||||
"react-redux": "^8.0.5",
|
||||
"strip-ansi": "^7.1.0",
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
|
||||
<span className="text-trueGray-400 ml-auto mr-4 text-xs">
|
||||
Highlight code to include as context.{" "}
|
||||
{highlightedCodeSections.length > 0 &&
|
||||
{highlightedCodeSections.length === 0 &&
|
||||
"Otherwise using entire currently open file."}
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -215,30 +215,35 @@ function GUI(props: GUIProps) {
|
|||
mainTextInputRef.current.value = "";
|
||||
if (!client) return;
|
||||
|
||||
setWaitingForSteps(true);
|
||||
|
||||
if (
|
||||
history?.timeline.length &&
|
||||
history.timeline[history.current_index].step.name ===
|
||||
history &&
|
||||
history.current_index >= 0 &&
|
||||
history.current_index < history.timeline.length
|
||||
) {
|
||||
if (
|
||||
history.timeline[history.current_index].step.name ===
|
||||
"Waiting for user input"
|
||||
) {
|
||||
if (input.trim() === "") return;
|
||||
onStepUserInput(input, history!.current_index);
|
||||
} else if (
|
||||
history?.timeline.length &&
|
||||
history.timeline[history.current_index].step.name ===
|
||||
) {
|
||||
if (input.trim() === "") return;
|
||||
onStepUserInput(input, history!.current_index);
|
||||
return;
|
||||
} else if (
|
||||
history.timeline[history.current_index].step.name ===
|
||||
"Waiting for user confirmation"
|
||||
) {
|
||||
onStepUserInput("ok", history!.current_index);
|
||||
} else {
|
||||
if (input.trim() === "") return;
|
||||
|
||||
client.sendMainInput(input);
|
||||
setUserInputQueue((queue) => {
|
||||
return [...queue, input];
|
||||
});
|
||||
) {
|
||||
onStepUserInput("ok", history!.current_index);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (input.trim() === "") return;
|
||||
|
||||
setWaitingForSteps(true);
|
||||
client.sendMainInput(input);
|
||||
setUserInputQueue((queue) => {
|
||||
return [...queue, input];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const onStepUserInput = (input: string, index: number) => {
|
||||
|
|
|
|||
7
extension/src/__mocks__/vscode.ts
Normal file
7
extension/src/__mocks__/vscode.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
const vscode = {
|
||||
window: {
|
||||
onDidChangeVisibleTextEditors: jest.fn(),
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = vscode;
|
||||
|
|
@ -4,7 +4,6 @@ const exec = util.promisify(require("child_process").exec);
|
|||
const { spawn } = require("child_process");
|
||||
import * as path from "path";
|
||||
import * as fs from "fs";
|
||||
import rebuild from "@electron/rebuild";
|
||||
import { getContinueServerUrl } from "../bridge";
|
||||
import fetch from "node-fetch";
|
||||
import * as vscode from "vscode";
|
||||
|
|
@ -60,7 +59,7 @@ async function runCommand(cmd: string): Promise<[string, string | undefined]> {
|
|||
return [stdout, stderr];
|
||||
}
|
||||
|
||||
async function getPythonPipCommands() {
|
||||
export async function getPythonPipCommands() {
|
||||
var [stdout, stderr] = await runCommand("python3 --version");
|
||||
let pythonCmd = "python3";
|
||||
if (stderr) {
|
||||
|
|
@ -111,10 +110,8 @@ async function getPythonPipCommands() {
|
|||
);
|
||||
throw new Error("Python3.8 or greater is not installed.");
|
||||
}
|
||||
} else {
|
||||
pythonCmd = `python${major}.${minor}`;
|
||||
pipCmd = `pip${major}.${minor}`;
|
||||
}
|
||||
|
||||
return [pythonCmd, pipCmd];
|
||||
}
|
||||
|
||||
|
|
@ -368,16 +365,6 @@ export async function startContinuePythonServer() {
|
|||
});
|
||||
}
|
||||
|
||||
async function installNodeModules() {
|
||||
console.log("Rebuilding node-pty for Continue extension...");
|
||||
await rebuild({
|
||||
buildPath: getExtensionUri().fsPath, // Folder containing node_modules
|
||||
electronVersion: "19.1.8",
|
||||
onlyModules: ["node-pty"],
|
||||
});
|
||||
console.log("Successfully rebuilt node-pty");
|
||||
}
|
||||
|
||||
export function isPythonEnvSetup(): boolean {
|
||||
let pathToEnvCfg = getExtensionUri().fsPath + "/scripts/env/pyvenv.cfg";
|
||||
return fs.existsSync(path.join(pathToEnvCfg));
|
||||
|
|
|
|||
70
extension/src/activation/test/environmentSetup.test.ts
Normal file
70
extension/src/activation/test/environmentSetup.test.ts
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
const child_process = require("child_process");
|
||||
import { platform } from "os";
|
||||
import { getPythonPipCommands } from "../environmentSetup";
|
||||
|
||||
jest.mock("os");
|
||||
jest.mock("child_process");
|
||||
|
||||
function mockPythonVersionMappings(mappings: { [pythonCmd: string]: string }) {
|
||||
(child_process.exec as jest.Mock).mockImplementation(
|
||||
(command: string, options: any) => {
|
||||
const pythonCmd = command.split(" ")[0];
|
||||
if (pythonCmd in mappings) {
|
||||
return Promise.resolve([mappings[pythonCmd], ""]);
|
||||
} else {
|
||||
return Promise.resolve(["", stubStderr]);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const stubStderr =
|
||||
"This is a stub stderr, but will be checked only for existence.";
|
||||
describe("getPythonPipCommands", () => {
|
||||
describe("on Windows", () => {
|
||||
it("should return the correct Python and Pip commands", async () => {
|
||||
(platform as jest.Mock).mockReturnValue("win32");
|
||||
mockPythonVersionMappings({
|
||||
python: "Python 3.8.0",
|
||||
});
|
||||
|
||||
const [pythonCmd, pipCmd] = await getPythonPipCommands();
|
||||
|
||||
expect(pythonCmd).toBe("python");
|
||||
expect(pipCmd).toBe("pip");
|
||||
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
describe("on MacOS", () => {
|
||||
(platform as jest.Mock).mockReturnValue("darwin");
|
||||
it("should check through all python versions after finding 3.7", async () => {
|
||||
mockPythonVersionMappings({
|
||||
python: "",
|
||||
python3: "Python 3.7.0",
|
||||
"python3.11": "Python 3.11.0",
|
||||
});
|
||||
|
||||
const [pythonCmd, pipCmd] = await getPythonPipCommands();
|
||||
|
||||
expect(pythonCmd).toBe("python3.11");
|
||||
expect(pipCmd).toBe("pip3.11");
|
||||
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("should use python3 if that maps to valid version", async () => {
|
||||
mockPythonVersionMappings({
|
||||
python: "",
|
||||
python3: "Python 3.8.0",
|
||||
});
|
||||
|
||||
const [pythonCmd, pipCmd] = await getPythonPipCommands();
|
||||
|
||||
expect(pythonCmd).toBe("python3");
|
||||
expect(pipCmd).toBe("pip3");
|
||||
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
import { test, describe } from "mocha";
|
||||
import * as assert from "assert";
|
||||
import { PythonTracebackSnooper } from "../../terminal/snoopers";
|
||||
|
||||
suite("Snoopers", () => {
|
||||
suite("PythonTracebackSnooper", () => {
|
||||
test("should detect traceback given all at once", async () => {
|
||||
let traceback = `Traceback (most recent call last):
|
||||
File "/Users/natesesti/Desktop/continue/extension/examples/python/main.py", line 10, in <module>
|
||||
sum(first, second)
|
||||
File "/Users/natesesti/Desktop/continue/extension/examples/python/sum.py", line 2, in sum
|
||||
return a + b
|
||||
TypeError: unsupported operand type(s) for +: 'int' and 'str'`;
|
||||
let returnedTraceback = await new Promise((resolve) => {
|
||||
let callback = (data: string) => {
|
||||
resolve(data);
|
||||
};
|
||||
let snooper = new PythonTracebackSnooper(callback);
|
||||
snooper.onData(traceback);
|
||||
});
|
||||
assert(
|
||||
returnedTraceback === traceback,
|
||||
"Detected \n" + returnedTraceback
|
||||
);
|
||||
});
|
||||
test("should detect traceback given in chunks", () => {});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue