merge main
This commit is contained in:
commit
7ea7df8980
129 changed files with 2390 additions and 853 deletions
4
.changes/unreleased/Added-20241113-165958.yaml
Normal file
4
.changes/unreleased/Added-20241113-165958.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
project: extensions/vscode
|
||||
kind: Added
|
||||
body: .continuerules file to set system prompt
|
||||
time: 2024-11-13T16:59:58.544875-08:00
|
||||
4
.changes/unreleased/Added-20241113-170006.yaml
Normal file
4
.changes/unreleased/Added-20241113-170006.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
project: extensions/vscode
|
||||
kind: Added
|
||||
body: .prompt files v2
|
||||
time: 2024-11-13T17:00:06.855468-08:00
|
||||
2
.github/workflows/auto-assign.yaml
vendored
2
.github/workflows/auto-assign.yaml
vendored
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
uses: pozil/auto-assign-issue@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.CI_GITHUB_TOKEN }}
|
||||
assignees: sestinj,Patrick-Erichsen
|
||||
assignees: sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa
|
||||
numOfAssignee: 1
|
||||
- name: "Add default labels"
|
||||
uses: actions-ecosystem/action-add-labels@v1
|
||||
|
|
|
|||
22
.github/workflows/main.yaml
vendored
22
.github/workflows/main.yaml
vendored
|
|
@ -213,8 +213,8 @@ jobs:
|
|||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
|
||||
- name: Pull latest changes
|
||||
run: git pull origin main
|
||||
- name: Pull latest changes from release
|
||||
run: git fetch origin ${{ github.ref }} && git checkout ${{ github.ref }}
|
||||
|
||||
# 1. Download the artifacts
|
||||
- uses: actions/download-artifact@v4
|
||||
|
|
@ -237,21 +237,3 @@ jobs:
|
|||
run: |
|
||||
cd extensions/vscode
|
||||
npx ovsx publish -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix
|
||||
|
||||
# 4. Update the package.json version and push changes
|
||||
# - name: Update version in package.json
|
||||
# run: |
|
||||
# cd extensions/vscode
|
||||
# npm version patch
|
||||
|
||||
# - name: Commit changes
|
||||
# run: |
|
||||
# git config --local user.email "action@github.com"
|
||||
# git config --local user.name "GitHub Action"
|
||||
# git commit -am "💚 Update package.json version [skip ci]"
|
||||
|
||||
# - name: Push changes
|
||||
# uses: ad-m/github-push-action@master
|
||||
# with:
|
||||
# github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# branch: ${{ github.ref }}
|
||||
|
|
|
|||
1
.instructions
Normal file
1
.instructions
Normal file
|
|
@ -0,0 +1 @@
|
|||
Give concise responses.
|
||||
33
binary/package-lock.json
generated
33
binary/package-lock.json
generated
|
|
@ -74,7 +74,7 @@
|
|||
"jsdom": "^24.0.0",
|
||||
"launchdarkly-node-client-sdk": "^3.2.0",
|
||||
"llm-code-highlighter": "^0.0.14",
|
||||
"lru-cache": "^10.2.2",
|
||||
"lru-cache": "^11.0.2",
|
||||
"mac-ca": "^3.1.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"node-html-markdown": "^1.3.0",
|
||||
|
|
@ -99,6 +99,7 @@
|
|||
"vectordb": "^0.4.20",
|
||||
"web-tree-sitter": "^0.21.0",
|
||||
"win-ca": "^3.5.1",
|
||||
"wink-nlp-utils": "^2.1.0",
|
||||
"workerpool": "^9.1.3",
|
||||
"yaml": "^2.4.2",
|
||||
"zod": "^3.23.8"
|
||||
|
|
@ -135,12 +136,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@75lb/deep-merge": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.1.tgz",
|
||||
"integrity": "sha512-xvgv6pkMGBA6GwdyJbNAnDmfAIR/DfWhrj9jgWh3TY7gRm3KO46x/GPjRg6wJ0nOepwqrNxFfojebh0Df4h4Tw==",
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.2.tgz",
|
||||
"integrity": "sha512-08K9ou5VNbheZFxM5tDWoqjA3ImC50DiuuJ2tj1yEPRfkp8lLLg6XAaJ4On+a0yAXor/8ay5gHnAIshRM44Kpw==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"lodash.assignwith": "^4.2.0",
|
||||
"lodash": "^4.17.21",
|
||||
"typical": "^7.1.1"
|
||||
},
|
||||
"engines": {
|
||||
|
|
@ -2749,12 +2750,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/braces": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
||||
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"fill-range": "^7.0.1"
|
||||
"fill-range": "^7.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
|
|
@ -3545,9 +3546,9 @@
|
|||
"optional": true
|
||||
},
|
||||
"node_modules/fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
||||
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"to-regex-range": "^5.0.1"
|
||||
|
|
@ -5037,10 +5038,10 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash.assignwith": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz",
|
||||
"integrity": "sha512-ZznplvbvtjK2gMvnQ1BR/zqPFZmS6jbK4p+6Up4xcRYA7yMIwxHCfbTcrYxXKzzqLsQ05eJPVznEW3tuwV7k1g==",
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/lodash.camelcase": {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { IDE } from "../..";
|
|||
import { RangeInFileWithContents } from "../../commands/util";
|
||||
import { PrecalculatedLruCache } from "../../util/LruCache";
|
||||
import {
|
||||
TSQueryType,
|
||||
getFullLanguageName,
|
||||
getParserForFile,
|
||||
getQueryForFile,
|
||||
} from "../../util/treeSitter";
|
||||
|
|
@ -47,7 +47,11 @@ export class ImportDefinitionsService {
|
|||
},
|
||||
],
|
||||
});
|
||||
const query = await getQueryForFile(filepath, TSQueryType.Imports);
|
||||
const language = getFullLanguageName(filepath);
|
||||
const query = await getQueryForFile(
|
||||
filepath,
|
||||
`import-queries/${language}.scm`,
|
||||
);
|
||||
if (!query) {
|
||||
return {
|
||||
imports: {},
|
||||
|
|
|
|||
|
|
@ -4,11 +4,31 @@ import { LRUCache } from "lru-cache";
|
|||
import Parser from "web-tree-sitter";
|
||||
|
||||
import { IDE } from "../../..";
|
||||
import { getQueryForFile } from "../../../util/treeSitter";
|
||||
import {
|
||||
getFullLanguageName,
|
||||
getQueryForFile,
|
||||
IGNORE_PATH_PATTERNS,
|
||||
LanguageName,
|
||||
} from "../../../util/treeSitter";
|
||||
import { AstPath } from "../../util/ast";
|
||||
import { ImportDefinitionsService } from "../ImportDefinitionsService";
|
||||
import { AutocompleteSnippet } from "../ranking";
|
||||
|
||||
function getSyntaxTreeString(
|
||||
node: Parser.SyntaxNode,
|
||||
indent: string = "",
|
||||
): string {
|
||||
let result = "";
|
||||
const nodeInfo = `${node.type} [${node.startPosition.row}:${node.startPosition.column} - ${node.endPosition.row}:${node.endPosition.column}]`;
|
||||
result += `${indent}${nodeInfo}\n`;
|
||||
|
||||
for (const child of node.children) {
|
||||
result += getSyntaxTreeString(child, indent + " ");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export class RootPathContextService {
|
||||
private cache = new LRUCache<string, AutocompleteSnippet[]>({
|
||||
max: 100,
|
||||
|
|
@ -24,10 +44,13 @@ export class RootPathContextService {
|
|||
}
|
||||
|
||||
private static TYPES_TO_USE = new Set([
|
||||
"arrow_function",
|
||||
"generator_function_declaration",
|
||||
"program",
|
||||
"function_declaration",
|
||||
"function_definition",
|
||||
"method_definition",
|
||||
"method_declaration",
|
||||
"class_declaration",
|
||||
"class_definition",
|
||||
]);
|
||||
|
|
@ -51,6 +74,7 @@ export class RootPathContextService {
|
|||
node: Parser.SyntaxNode,
|
||||
): Promise<AutocompleteSnippet[]> {
|
||||
const snippets: AutocompleteSnippet[] = [];
|
||||
const language = getFullLanguageName(filepath);
|
||||
|
||||
let query: Parser.Query | undefined;
|
||||
switch (node.type) {
|
||||
|
|
@ -58,9 +82,13 @@ export class RootPathContextService {
|
|||
this.importDefinitionsService.get(filepath);
|
||||
break;
|
||||
default:
|
||||
// const type = node.type;
|
||||
// console.log(getSyntaxTreeString(node));
|
||||
// debugger;
|
||||
|
||||
query = await getQueryForFile(
|
||||
filepath,
|
||||
`root-path-context-queries/${node.type}`,
|
||||
`root-path-context-queries/${language}/${node.type}.scm`,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
|
@ -69,15 +97,24 @@ export class RootPathContextService {
|
|||
return snippets;
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
query.matches(node).map(async (match) => {
|
||||
for (const item of match.captures) {
|
||||
const queries = query.matches(node).map(async (match) => {
|
||||
for (const item of match.captures) {
|
||||
try {
|
||||
const endPosition = item.node.endPosition;
|
||||
const newSnippets = await this.getSnippets(filepath, endPosition);
|
||||
const newSnippets = await this.getSnippets(
|
||||
filepath,
|
||||
endPosition,
|
||||
language,
|
||||
);
|
||||
snippets.push(...newSnippets);
|
||||
} catch (e) {
|
||||
debugger;
|
||||
throw e;
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(queries);
|
||||
|
||||
return snippets;
|
||||
}
|
||||
|
|
@ -85,6 +122,7 @@ export class RootPathContextService {
|
|||
private async getSnippets(
|
||||
filepath: string,
|
||||
endPosition: Parser.Point,
|
||||
language: LanguageName,
|
||||
): Promise<AutocompleteSnippet[]> {
|
||||
const definitions = await this.ide.gotoDefinition({
|
||||
filepath,
|
||||
|
|
@ -94,10 +132,18 @@ export class RootPathContextService {
|
|||
},
|
||||
});
|
||||
const newSnippets = await Promise.all(
|
||||
definitions.map(async (def) => ({
|
||||
...def,
|
||||
contents: await this.ide.readRangeInFile(def.filepath, def.range),
|
||||
})),
|
||||
definitions
|
||||
.filter((definition) => {
|
||||
const isIgnoredPath = IGNORE_PATH_PATTERNS[language]?.some(
|
||||
(pattern) => pattern.test(definition.filepath),
|
||||
);
|
||||
|
||||
return !isIgnoredPath;
|
||||
})
|
||||
.map(async (def) => ({
|
||||
...def,
|
||||
contents: await this.ide.readRangeInFile(def.filepath, def.range),
|
||||
})),
|
||||
);
|
||||
|
||||
return newSnippets;
|
||||
|
|
@ -115,6 +161,8 @@ export class RootPathContextService {
|
|||
RootPathContextService.TYPES_TO_USE.has(node.type),
|
||||
)) {
|
||||
const key = RootPathContextService.keyFromNode(parentKey, astNode);
|
||||
// const type = astNode.type;
|
||||
// debugger;
|
||||
|
||||
const foundInCache = this.cache.get(key);
|
||||
const newSnippets =
|
||||
|
|
|
|||
|
|
@ -1,63 +1,56 @@
|
|||
import { PYTHON_TEST_CASES, TYPESCRIPT_TEST_CASES } from "./testCases";
|
||||
import { testRootPathContext } from "./testUtils";
|
||||
|
||||
const TEST_CASES = [
|
||||
...PYTHON_TEST_CASES,
|
||||
...TYPESCRIPT_TEST_CASES,
|
||||
{
|
||||
nodeType: "function_declaration",
|
||||
fileName: "file1.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 10, character: 24 },
|
||||
nodeType: "function_definition",
|
||||
fileName: "file1.php",
|
||||
language: "PHP",
|
||||
cursorPosition: { line: 12, character: 32 },
|
||||
definitionPositions: [
|
||||
{ row: 9, column: 34 }, // Person
|
||||
{ row: 9, column: 44 }, // Address
|
||||
{ row: 10, column: 26 }, // Person
|
||||
{ row: 10, column: 44 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "method_declaration",
|
||||
fileName: "file1.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 22, character: 30 },
|
||||
fileName: "file1.php",
|
||||
language: "PHP",
|
||||
cursorPosition: { line: 26, character: 35 },
|
||||
definitionPositions: [
|
||||
{ row: 13, column: 29 }, // BaseClass
|
||||
{ row: 13, column: 55 }, // FirstInterface
|
||||
{ row: 13, column: 72 }, // SecondInterface
|
||||
{ row: 21, column: 33 }, // Person
|
||||
{ row: 21, column: 43 }, // Address
|
||||
{ row: 15, column: 29 }, // BaseClass
|
||||
{ row: 15, column: 55 }, // FirstInterface
|
||||
{ row: 15, column: 72 }, // SecondInterface
|
||||
{ row: 25, column: 43 }, // Person
|
||||
{ row: 25, column: 61 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition",
|
||||
fileName: "file1.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 4, character: 25 },
|
||||
nodeType: "function_declaration",
|
||||
fileName: "file1.go",
|
||||
language: "Go",
|
||||
cursorPosition: { line: 7, character: 21 },
|
||||
definitionPositions: [
|
||||
{ row: 3, column: 30 }, // Person
|
||||
{ row: 3, column: 42 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition (inside a class)",
|
||||
fileName: "file1.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 12, character: 33 },
|
||||
definitionPositions: [
|
||||
{ row: 6, column: 21 }, // BaseClass
|
||||
{ row: 6, column: 33 }, // Collection
|
||||
{ row: 11, column: 47 }, // Person
|
||||
{ row: 11, column: 59 }, // Address
|
||||
{ row: 6, column: 33 }, // models.User
|
||||
{ row: 6, column: 50 }, // models.Address
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
describe("RootPathContextService", () => {
|
||||
test.each(TEST_CASES)(
|
||||
"Should look for correct type definitions when editing inside a $nodeType in $language",
|
||||
async ({ fileName, cursorPosition, definitionPositions }) => {
|
||||
await testRootPathContext(
|
||||
"files",
|
||||
fileName,
|
||||
cursorPosition,
|
||||
definitionPositions,
|
||||
);
|
||||
},
|
||||
);
|
||||
describe("should look for correct type definitions", () => {
|
||||
test.each(TEST_CASES)(
|
||||
"$language: $nodeType",
|
||||
async ({ fileName, cursorPosition, definitionPositions }) => {
|
||||
await testRootPathContext(
|
||||
"files",
|
||||
fileName,
|
||||
cursorPosition,
|
||||
definitionPositions,
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"core/autocomplete/context/root-path-context/test/files/models"
|
||||
)
|
||||
|
||||
func getAddress(user *models.User) *models.Address {
|
||||
return user.Address
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace BaseNamespace;
|
||||
|
||||
use BaseNamespace\BaseClass;
|
||||
use BaseNamespace\Interfaces\FirstInterface;
|
||||
use BaseNamespace\Interfaces\SecondInterface;
|
||||
use BaseNamespace\Person;
|
||||
use BaseNamespace\Address;
|
||||
|
||||
function getAddress(Person $person): Address
|
||||
{
|
||||
return $person->getAddress();
|
||||
}
|
||||
|
||||
class Group extends BaseClass implements FirstInterface, SecondInterface
|
||||
{
|
||||
private array $people;
|
||||
|
||||
public function __construct(array $people)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->people = $people;
|
||||
}
|
||||
|
||||
public function getPersonAddress(Person $person): Address
|
||||
{
|
||||
return getAddress($person);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
from .base_module import BaseClass, Collection, Person, Address
|
||||
from typing import List
|
||||
|
||||
def get_address(person: Person) -> Address:
|
||||
return person.address
|
||||
|
||||
class Group(BaseClass, Collection):
|
||||
def __init__(self, people: List[Person]) -> None:
|
||||
super().__init__()
|
||||
self.people = people
|
||||
|
||||
def get_person_address(self, person: Person) -> Address:
|
||||
return get_address(person)
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import {
|
||||
Address,
|
||||
Person,
|
||||
BaseClass,
|
||||
FirstInterface,
|
||||
SecondInterface,
|
||||
// @ts-ignore
|
||||
} from "./types";
|
||||
|
||||
function getAddress(person: Person): Address {
|
||||
return person.address;
|
||||
}
|
||||
|
||||
class Group extends BaseClass implements FirstInterface, SecondInterface {
|
||||
people: Person[];
|
||||
|
||||
constructor(people: Person[]) {
|
||||
super();
|
||||
this.people = people;
|
||||
}
|
||||
|
||||
getPersonAddress(person: Person): Address {
|
||||
return getAddress(person);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
class Group(BaseClass, Person):
|
||||
pass
|
||||
|
||||
class Group(metaclass=MetaGroup):
|
||||
pass
|
||||
|
||||
class Group(BaseClass[Address], Gathering[Person]):
|
||||
pass
|
||||
|
||||
class Group(List[Address], Person[str]):
|
||||
pass
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
from typing import List, Union, TypeVar, Generic
|
||||
|
||||
T = TypeVar('T')
|
||||
|
||||
class Address:
|
||||
pass
|
||||
|
||||
class Person:
|
||||
pass
|
||||
|
||||
class PersonWithGeneric(Generic[T]):
|
||||
pass
|
||||
|
||||
|
||||
def get_address(person: Person) -> Address:
|
||||
pass
|
||||
|
||||
def get_group_address(people: Group[Person]) -> Group[Address]:
|
||||
pass
|
||||
|
||||
def log_person(person: Person) -> None:
|
||||
pass
|
||||
|
||||
def get_hardcoded_address() -> Address:
|
||||
pass
|
||||
|
||||
def log_person_or_address(value: Union[Person, Address]) -> Union[Person, Address]:
|
||||
pass
|
||||
|
||||
def log_person_and_address(person: Person, address: Address) -> None:
|
||||
pass
|
||||
|
||||
def get_address_generator(person: Person) -> Generator[Address, None, None]:
|
||||
yield
|
||||
|
||||
|
||||
class Group:
|
||||
def log_person_and_address(self, person: Person, address: Address) -> None:
|
||||
pass
|
||||
|
||||
async def get_person(address: Address) -> Person:
|
||||
pass
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// @ts-nocheck
|
||||
|
||||
const getAddress = (person: Person): Address => {
|
||||
// TODO
|
||||
};
|
||||
|
||||
const logPerson = (person: Person) => {
|
||||
// TODO
|
||||
};
|
||||
|
||||
const getHardcodedAddress = (): Address => {
|
||||
// TODO
|
||||
};
|
||||
|
||||
const getAddresses = (people: Person[]): Address[] => {
|
||||
// TODO
|
||||
};
|
||||
|
||||
const logPersonWithAddres = (person: Person<Address>): Person<Address> => {
|
||||
// TODO
|
||||
};
|
||||
|
||||
const logPersonOrAddress = (person: Person | Address): Person | Address => {
|
||||
// TODO
|
||||
};
|
||||
|
||||
const logPersonAndAddress = (person: Person, address: Address) => {
|
||||
// TODO
|
||||
};
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
// @ts-nocheck
|
||||
|
||||
class Group {
|
||||
getPersonAddress(person: Person): Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
getHardcodedAddress(): Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
addPerson(person: Person) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
addPeople(people: Person[]) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
getAddresses(people: Person[]): Address[] {
|
||||
// TODO
|
||||
}
|
||||
|
||||
logPersonWithAddress(person: Person<Address>): Person<Address> {
|
||||
// TODO
|
||||
}
|
||||
|
||||
logPersonOrAddress(person: Person | Address): Person | Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
logPersonAndAddress(person: Person, address: Address) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// @ts-nocheck
|
||||
|
||||
class Group extends BaseClass {}
|
||||
|
||||
class Group implements FirstInterface {}
|
||||
|
||||
class Group extends BaseClass implements FirstInterface, SecondInterface {}
|
||||
|
||||
class Group extends BaseClass<User> implements FirstInterface<User> {}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// @ts-nocheck
|
||||
|
||||
function getAddress(person: Person): Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function getFirstAddress(people: Person[]): Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function logPerson(person: Person) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function getHardcodedAddress(): Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function getAddresses(people: Person[]): Address[] {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function logPersonWithAddress(person: Person<Address>): Person<Address> {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function logPersonOrAddress(person: Person | Address): Person | Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function logPersonAndAddress(person: Person, address: Address) {
|
||||
// TODO
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// @ts-nocheck
|
||||
|
||||
function* getAddress(person: Person): Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function* getFirstAddress(people: Person[]): Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function* logPerson(person: Person) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function* getHardcodedAddress(): Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function* getAddresses(people: Person[]): Address[] {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function* logPersonWithAddress(person: Person<Address>): Person<Address> {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function* logPersonOrAddress(person: Person | Address): Person | Address {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function* logPersonAndAddress(person: Person, address: Address) {
|
||||
// TODO
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
export * from "./python";
|
||||
export * from "./typescript";
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
export const FUNCTIONS = [
|
||||
{
|
||||
nodeType: "function_definition with argument and return type",
|
||||
fileName: "python/functions.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 15, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 14, column: 30 }, // Person
|
||||
{ row: 14, column: 42 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType:
|
||||
"function_definition with generic argument and generic return type",
|
||||
fileName: "python/functions.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 18, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 17, column: 35 }, // Group
|
||||
{ row: 17, column: 42 }, // Person
|
||||
{ row: 17, column: 53 }, // Group
|
||||
{ row: 17, column: 61 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition with single argument and None return type",
|
||||
fileName: "python/functions.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 21, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 20, column: 29 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition with no arguments and single return type",
|
||||
fileName: "python/functions.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 24, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 23, column: 38 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition with Union arguments and Union return type",
|
||||
fileName: "python/functions.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 27, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 26, column: 45 }, // Person
|
||||
{ row: 26, column: 54 }, // Address
|
||||
{ row: 26, column: 72 }, // Person
|
||||
{ row: 26, column: 81 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType:
|
||||
"function_definition with multiple arguments and None return type",
|
||||
fileName: "python/functions.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 30, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 29, column: 41 }, // Person
|
||||
{ row: 29, column: 59 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition with one argument and Generator return type",
|
||||
fileName: "python/functions.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 33, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 32, column: 40 }, // Person
|
||||
{ row: 32, column: 62 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition inside a class",
|
||||
fileName: "python/functions.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 38, character: 12 },
|
||||
definitionPositions: [
|
||||
{ row: 37, column: 51 }, // Person
|
||||
{ row: 37, column: 69 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition of an async function",
|
||||
fileName: "python/functions.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 41, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 40, column: 37 }, // Address
|
||||
{ row: 40, column: 48 }, // Person
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const CLASSES = [
|
||||
{
|
||||
nodeType: "class_definition with multiple superclasses",
|
||||
fileName: "python/classes.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 1, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 0, column: 21 }, // BaseClass
|
||||
{ row: 0, column: 29 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "class_definition with multiple superclasses",
|
||||
fileName: "python/classes.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 4, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 3, column: 31 }, // MetaGroup
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "class_definition with generic superclasses",
|
||||
fileName: "python/classes.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 7, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 6, column: 21 }, // BaseClass
|
||||
{ row: 6, column: 29 }, // Address
|
||||
{ row: 6, column: 41 }, // Gathering
|
||||
{ row: 6, column: 48 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "class_definition with generic superclasses (built in types)",
|
||||
fileName: "python/classes.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 10, character: 8 },
|
||||
definitionPositions: [
|
||||
{ row: 9, column: 24 }, // Address
|
||||
{ row: 9, column: 33 }, // Person
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const PYTHON_TEST_CASES = [
|
||||
// ...FUNCTIONS,
|
||||
...CLASSES,
|
||||
];
|
||||
|
|
@ -0,0 +1,397 @@
|
|||
const FUNCTIONS = [
|
||||
{
|
||||
nodeType: "function_declaration with a param and a return type",
|
||||
fileName: "typescript/functions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 3, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 2, column: 34 }, // Person
|
||||
{ row: 2, column: 44 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_declaration with array param",
|
||||
fileName: "typescript/functions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 7, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 6, column: 39 }, // Person
|
||||
{ row: 6, column: 51 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_declaration without return type",
|
||||
fileName: "typescript/functions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 11, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 10, column: 33 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_declaration without params",
|
||||
fileName: "typescript/functions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 15, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 14, column: 39 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_declaration with array params and array return type",
|
||||
fileName: "typescript/functions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 19, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 18, column: 36 }, // Person
|
||||
{ row: 18, column: 48 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType:
|
||||
"function_declaration with generic params and generic return type",
|
||||
fileName: "typescript/functions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 23, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 22, column: 44 }, // Person
|
||||
{ row: 22, column: 52 }, // Address
|
||||
{ row: 22, column: 62 }, // Person
|
||||
{ row: 22, column: 70 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType:
|
||||
"function_declaration with union type params and union return type",
|
||||
fileName: "typescript/functions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 27, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 26, column: 42 }, // Person
|
||||
{ row: 26, column: 52 }, // Address
|
||||
{ row: 26, column: 61 }, // Person
|
||||
{ row: 26, column: 71 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_declaration with two arguments",
|
||||
fileName: "typescript/functions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 31, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 30, column: 43 }, // Person
|
||||
{ row: 30, column: 61 }, // Address
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const GENERATORS = [
|
||||
{
|
||||
nodeType: "function_declaration with a param and a return type",
|
||||
fileName: "typescript/generators.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 3, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 2, column: 35 }, // Person
|
||||
{ row: 2, column: 45 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_declaration with array param",
|
||||
fileName: "typescript/generators.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 7, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 6, column: 40 }, // Person
|
||||
{ row: 6, column: 52 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_declaration without return type",
|
||||
fileName: "typescript/generators.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 11, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 10, column: 34 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_declaration without params",
|
||||
fileName: "typescript/generators.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 15, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 14, column: 40 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_declaration with array params and array return type",
|
||||
fileName: "typescript/generators.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 19, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 18, column: 37 }, // Person
|
||||
{ row: 18, column: 49 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType:
|
||||
"function_declaration with generic params and generic return type",
|
||||
fileName: "typescript/generators.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 23, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 22, column: 45 }, // Person
|
||||
{ row: 22, column: 53 }, // Address
|
||||
{ row: 22, column: 63 }, // Person
|
||||
{ row: 22, column: 71 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType:
|
||||
"function_declaration with union type params and union return type",
|
||||
fileName: "typescript/generators.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 27, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 26, column: 43 }, // Person
|
||||
{ row: 26, column: 53 }, // Address
|
||||
{ row: 26, column: 62 }, // Person
|
||||
{ row: 26, column: 72 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_declaration with two arguments",
|
||||
fileName: "typescript/generators.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 31, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 30, column: 44 }, // Person
|
||||
{ row: 30, column: 62 }, // Address
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const ARROW_FUNCTIONS = [
|
||||
{
|
||||
nodeType: "arrow_function with a param and a return type",
|
||||
fileName: "typescript/arrowFunctions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 3, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 2, column: 34 }, // Person
|
||||
{ row: 2, column: 44 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "arrow_function without return type",
|
||||
fileName: "typescript/arrowFunctions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 7, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 6, column: 33 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "arrow_function without params",
|
||||
fileName: "typescript/arrowFunctions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 11, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 10, column: 39 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "arrow_function with array params and array return type",
|
||||
fileName: "typescript/arrowFunctions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 15, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 14, column: 36 }, // Person
|
||||
{ row: 14, column: 48 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "arrow_function with generic params and generic return type",
|
||||
fileName: "typescript/arrowFunctions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 19, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 18, column: 43 }, // Person
|
||||
{ row: 18, column: 51 }, // Address
|
||||
{ row: 18, column: 61 }, // Person
|
||||
{ row: 18, column: 69 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "arrow_function with union type params and union return type",
|
||||
fileName: "typescript/arrowFunctions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 23, character: 9 },
|
||||
definitionPositions: [
|
||||
{ row: 22, column: 42 }, // Person
|
||||
{ row: 22, column: 52 }, // Address
|
||||
{ row: 22, column: 61 }, // Person
|
||||
{ row: 22, column: 71 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "arrow_function with two arguments",
|
||||
fileName: "typescript/arrowFunctions.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 27, character: 11 },
|
||||
definitionPositions: [
|
||||
{ row: 26, column: 43 }, // Person
|
||||
{ row: 26, column: 61 }, // Address
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const CLASS_METHODS = [
|
||||
{
|
||||
nodeType: "method_declaration with a param and a return type",
|
||||
fileName: "typescript/classMethods.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 4, character: 11 },
|
||||
definitionPositions: [
|
||||
{ row: 3, column: 33 }, // Person
|
||||
{ row: 3, column: 43 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "method_declaration without arguments",
|
||||
fileName: "typescript/classMethods.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 8, character: 11 },
|
||||
definitionPositions: [
|
||||
{ row: 7, column: 32 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "method_declaration without return type",
|
||||
fileName: "typescript/classMethods.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 12, character: 11 },
|
||||
definitionPositions: [
|
||||
{ row: 11, column: 26 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "method_declaration with array type arguments",
|
||||
fileName: "typescript/classMethods.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 16, character: 11 },
|
||||
definitionPositions: [
|
||||
{ row: 15, column: 26 }, // Person
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType:
|
||||
"method_declaration with array type arguments and array type return",
|
||||
fileName: "typescript/classMethods.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 20, character: 11 },
|
||||
definitionPositions: [
|
||||
{ row: 19, column: 29 }, // Person
|
||||
{ row: 19, column: 41 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType:
|
||||
"method_declaration with with generic params and generic return type",
|
||||
fileName: "typescript/classMethods.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 24, character: 11 },
|
||||
definitionPositions: [
|
||||
{ row: 23, column: 37 }, // Person
|
||||
{ row: 23, column: 45 }, // Address
|
||||
{ row: 23, column: 55 }, // Person
|
||||
{ row: 23, column: 63 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "method_declaration with union type params and union return type",
|
||||
fileName: "typescript/classMethods.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 28, character: 11 },
|
||||
definitionPositions: [
|
||||
{ row: 27, column: 35 }, // Person
|
||||
{ row: 27, column: 45 }, // Address
|
||||
{ row: 27, column: 54 }, // Person
|
||||
{ row: 27, column: 64 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "method_declaration with two arguments",
|
||||
fileName: "typescript/classMethods.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 32, character: 11 },
|
||||
definitionPositions: [
|
||||
{ row: 31, column: 36 }, // Person
|
||||
{ row: 31, column: 54 }, // Address
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const CLASS_DEFINITIONS = [
|
||||
{
|
||||
nodeType: "class_declaration with base class",
|
||||
fileName: "typescript/classes.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 2, character: 31 },
|
||||
definitionPositions: [
|
||||
{ row: 2, column: 29 }, // BaseClass
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "class_declaration with interface",
|
||||
fileName: "typescript/classes.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 4, character: 39 },
|
||||
definitionPositions: [
|
||||
{ row: 4, column: 37 }, // FirstInterface
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "class_declaration with base class and multiple interfaces",
|
||||
fileName: "typescript/classes.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 6, character: 74 },
|
||||
definitionPositions: [
|
||||
{ row: 6, column: 29 }, // BaseClass
|
||||
{ row: 6, column: 55 }, // FirstInterface
|
||||
{ row: 6, column: 72 }, // SecondInterface
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "class_declaration with base class and multiple interfaces",
|
||||
fileName: "typescript/classes.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 6, character: 74 },
|
||||
definitionPositions: [
|
||||
{ row: 6, column: 29 }, // BaseClass
|
||||
{ row: 6, column: 55 }, // FirstInterface
|
||||
{ row: 6, column: 72 }, // SecondInterface
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "class_declaration with generic base class and generic interface",
|
||||
fileName: "typescript/classes.ts",
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 8, character: 69 },
|
||||
definitionPositions: [
|
||||
{ row: 8, column: 29 }, // BaseClass
|
||||
{ row: 8, column: 61 }, // FirstInterface
|
||||
{ row: 8, column: 34 }, // User
|
||||
{ row: 8, column: 66 }, // User
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const TYPESCRIPT_TEST_CASES = [
|
||||
...FUNCTIONS,
|
||||
...GENERATORS,
|
||||
...ARROW_FUNCTIONS,
|
||||
...CLASS_METHODS,
|
||||
...CLASS_DEFINITIONS,
|
||||
];
|
||||
|
|
@ -84,6 +84,7 @@ export async function testRootPathContext(
|
|||
index + 1,
|
||||
expect.any(String), // filepath argument
|
||||
position,
|
||||
expect.any(String), // language argument
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,4 +157,20 @@ describe("stopAtStopTokens", () => {
|
|||
|
||||
expect(output.join("")).toBe("Hello world!");
|
||||
});
|
||||
|
||||
it("should handle stop token when remaining buffer is smaller than maximum stop token length", async () => {
|
||||
const mockStream = createMockStream(["Hello world!STOP"]);
|
||||
const stopTokens: string[] = [
|
||||
"STOP",
|
||||
"STOP_TOKEN_THAT_IS_LARGER_THAN_BUFFER",
|
||||
];
|
||||
const result = stopAtStopTokens(mockStream, stopTokens);
|
||||
|
||||
const output = [];
|
||||
for await (const char of result) {
|
||||
output.push(char);
|
||||
}
|
||||
|
||||
expect(output.join("")).toBe("Hello world!");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ export async function* noFirstCharNewline(stream: AsyncGenerator<string>) {
|
|||
* 2. Otherwise, buffers incoming chunks and checks for stop tokens.
|
||||
* 3. Yields characters one by one if no stop token is found at the start of the buffer.
|
||||
* 4. Stops yielding and returns if a stop token is encountered.
|
||||
* 5. After the stream ends, yields any remaining buffered characters.
|
||||
* 5. After the stream ends, filters encountered stop tokens in remaining buffer.
|
||||
* 6. Yields any remaining buffered characters.
|
||||
*/
|
||||
export async function* stopAtStopTokens(
|
||||
stream: AsyncGenerator<string>,
|
||||
|
|
@ -106,6 +107,10 @@ export async function* stopAtStopTokens(
|
|||
}
|
||||
}
|
||||
}
|
||||
// Filter out the possible stop tokens from remaining buffer
|
||||
stopTokens.forEach((token) => {
|
||||
buffer = buffer.replace(token, "");
|
||||
});
|
||||
|
||||
// Yield any remaining characters in the buffer
|
||||
for (const char of buffer) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ export class AutocompleteLoggingService {
|
|||
|
||||
if (this._outcomes.has(completionId)) {
|
||||
const outcome = this._outcomes.get(completionId)!;
|
||||
outcome.accepted = true;
|
||||
this.logAutocompleteOutcome(outcome);
|
||||
this._outcomes.delete(completionId);
|
||||
return outcome;
|
||||
|
|
@ -94,7 +95,6 @@ export class AutocompleteLoggingService {
|
|||
}
|
||||
|
||||
private logAutocompleteOutcome(outcome: AutocompleteOutcome) {
|
||||
outcome.accepted = true;
|
||||
logDevData("autocomplete", outcome);
|
||||
const { prompt, completion, prefix, suffix, ...restOfOutcome } = outcome;
|
||||
void Telemetry.capture(
|
||||
|
|
|
|||
27
core/config/getSystemPromptDotFile.ts
Normal file
27
core/config/getSystemPromptDotFile.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { IDE } from "..";
|
||||
|
||||
export const SYSTEM_PROMPT_DOT_FILE = ".continuerules";
|
||||
|
||||
export async function getSystemPromptDotFile(ide: IDE): Promise<string | null> {
|
||||
const dirs = await ide.getWorkspaceDirs();
|
||||
|
||||
let prompts: string[] = [];
|
||||
const pathSep = await ide.pathSep();
|
||||
for (const dir of dirs) {
|
||||
const dotFile = `${dir}${pathSep}${SYSTEM_PROMPT_DOT_FILE}`;
|
||||
if (await ide.fileExists(dotFile)) {
|
||||
try {
|
||||
const content = await ide.readFile(dotFile);
|
||||
prompts.push(content);
|
||||
} catch (e) {
|
||||
// ignore if file doesn't exist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!prompts.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return prompts.join("\n\n");
|
||||
}
|
||||
|
|
@ -64,6 +64,7 @@ import {
|
|||
defaultSlashCommandsJetBrains,
|
||||
defaultSlashCommandsVscode,
|
||||
} from "./default";
|
||||
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
||||
import {
|
||||
DEFAULT_PROMPTS_FOLDER,
|
||||
getPromptFiles,
|
||||
|
|
@ -735,6 +736,11 @@ async function loadFullConfigNode(
|
|||
return { errors, config: undefined, configLoadInterrupted: true };
|
||||
}
|
||||
|
||||
const systemPromptDotFile = await getSystemPromptDotFile(ide);
|
||||
if (systemPromptDotFile) {
|
||||
serialized.systemMessage = systemPromptDotFile;
|
||||
}
|
||||
|
||||
// Convert serialized to intermediate config
|
||||
let intermediate = await serializedToIntermediateConfig(serialized, ide);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,18 @@ export function validateConfig(config: SerializedContinueConfig) {
|
|||
message: `Model at index ${index} has an invalid 'provider'.`,
|
||||
});
|
||||
}
|
||||
|
||||
if (model.contextLength && model.completionOptions?.maxTokens) {
|
||||
const difference =
|
||||
model.contextLength - model.completionOptions.maxTokens;
|
||||
|
||||
if (difference < 1000) {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `Model "${model.title}" has a contextLength of ${model.contextLength} and a maxTokens of ${model.completionOptions.maxTokens}. This leaves only ${difference} tokens for input context and will likely result in your inputs being truncated.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class DocsContextProvider extends BaseContextProvider {
|
|||
await docsService.isJetBrainsAndPreIndexedDocsProvider();
|
||||
|
||||
if (isJetBrainsAndPreIndexedDocsProvider) {
|
||||
await extras.ide.showToast(
|
||||
void extras.ide.showToast(
|
||||
"error",
|
||||
`${DocsService.preIndexedDocsEmbeddingsProvider.id} is configured as ` +
|
||||
"the embeddings provider, but it cannot be used with JetBrains. " +
|
||||
|
|
|
|||
76
core/core.ts
76
core/core.ts
|
|
@ -150,7 +150,7 @@ export class Core {
|
|||
void this.ide.getWorkspaceDirs().then(async (dirs) => {
|
||||
// Respect pauseCodebaseIndexOnStart user settings
|
||||
if (ideSettings.pauseCodebaseIndexOnStart) {
|
||||
await this.messenger.request("indexProgress", {
|
||||
void this.messenger.request("indexProgress", {
|
||||
progress: 1,
|
||||
desc: "Initial Indexing Skipped",
|
||||
status: "paused",
|
||||
|
|
@ -693,6 +693,11 @@ export class Core {
|
|||
const dirs = data?.dirs ?? (await this.ide.getWorkspaceDirs());
|
||||
await this.refreshCodebaseIndex(dirs);
|
||||
});
|
||||
on("index/forceReIndexFiles", async ({ data }) => {
|
||||
if (data?.files?.length) {
|
||||
await this.refreshCodebaseIndexFiles(data.files);
|
||||
}
|
||||
});
|
||||
on("index/setPaused", (msg) => {
|
||||
new GlobalContext().update("indexingPaused", msg.data);
|
||||
this.indexingPauseToken.paused = msg.data;
|
||||
|
|
@ -728,14 +733,29 @@ export class Core {
|
|||
}
|
||||
|
||||
private indexingCancellationController: AbortController | undefined;
|
||||
private async sendIndexingErrorTelemetry(update: IndexingProgressUpdate) {
|
||||
console.debug(
|
||||
"Indexing failed with error: ",
|
||||
update.desc,
|
||||
update.debugInfo,
|
||||
);
|
||||
void Telemetry.capture(
|
||||
"indexing_error",
|
||||
{
|
||||
error: update.desc,
|
||||
stack: update.debugInfo,
|
||||
},
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
private async refreshCodebaseIndex(dirs: string[]) {
|
||||
private async refreshCodebaseIndex(paths: string[]) {
|
||||
if (this.indexingCancellationController) {
|
||||
this.indexingCancellationController.abort();
|
||||
}
|
||||
this.indexingCancellationController = new AbortController();
|
||||
for await (const update of (await this.codebaseIndexerPromise).refresh(
|
||||
dirs,
|
||||
for await (const update of (await this.codebaseIndexerPromise).refreshDirs(
|
||||
paths,
|
||||
this.indexingCancellationController.signal,
|
||||
)) {
|
||||
let updateToSend = { ...update };
|
||||
|
|
@ -749,19 +769,41 @@ export class Core {
|
|||
this.indexingState = updateToSend;
|
||||
|
||||
if (update.status === "failed") {
|
||||
console.debug(
|
||||
"Indexing failed with error: ",
|
||||
update.desc,
|
||||
update.debugInfo,
|
||||
);
|
||||
void Telemetry.capture(
|
||||
"indexing_error",
|
||||
{
|
||||
error: update.desc,
|
||||
stack: update.debugInfo,
|
||||
},
|
||||
false,
|
||||
);
|
||||
void this.sendIndexingErrorTelemetry(update);
|
||||
}
|
||||
}
|
||||
|
||||
this.messenger.send("refreshSubmenuItems", undefined);
|
||||
this.indexingCancellationController = undefined;
|
||||
}
|
||||
|
||||
private async refreshCodebaseIndexFiles(files: string[]) {
|
||||
// Can be cancelled by codebase index but not vice versa
|
||||
if (
|
||||
this.indexingCancellationController &&
|
||||
!this.indexingCancellationController.signal.aborted
|
||||
) {
|
||||
return console.debug(
|
||||
"Codebase indexing already in progress, skipping indexing of files\n" +
|
||||
files.join("\n"),
|
||||
);
|
||||
}
|
||||
this.indexingCancellationController = new AbortController();
|
||||
for await (const update of (await this.codebaseIndexerPromise).refreshFiles(
|
||||
files,
|
||||
)) {
|
||||
let updateToSend = { ...update };
|
||||
if (update.status === "failed") {
|
||||
updateToSend.status = "done";
|
||||
updateToSend.desc = "Indexing complete";
|
||||
updateToSend.progress = 1.0;
|
||||
}
|
||||
|
||||
void this.messenger.request("indexProgress", updateToSend);
|
||||
this.indexingState = updateToSend;
|
||||
|
||||
if (update.status === "failed") {
|
||||
void this.sendIndexingErrorTelemetry(update);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,17 @@ import Parser from "web-tree-sitter";
|
|||
import { getBasename, getLastNPathParts } from "../util/";
|
||||
import { migrate } from "../util/paths";
|
||||
import {
|
||||
TSQueryType,
|
||||
getFullLanguageName,
|
||||
getParserForFile,
|
||||
getQueryForFile,
|
||||
} from "../util/treeSitter";
|
||||
|
||||
import { DatabaseConnection, SqliteDb, tagToString, truncateSqliteLikePattern } from "./refreshIndex";
|
||||
import {
|
||||
DatabaseConnection,
|
||||
SqliteDb,
|
||||
tagToString,
|
||||
truncateSqliteLikePattern,
|
||||
} from "./refreshIndex";
|
||||
import {
|
||||
IndexResultType,
|
||||
MarkCompleteCallback,
|
||||
|
|
@ -31,7 +36,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
|
|||
relativeExpectedTime: number = 1;
|
||||
artifactId = "codeSnippets";
|
||||
|
||||
constructor(private readonly ide: IDE) { }
|
||||
constructor(private readonly ide: IDE) {}
|
||||
|
||||
private static async _createTables(db: DatabaseConnection) {
|
||||
await db.exec(`CREATE TABLE IF NOT EXISTS code_snippets (
|
||||
|
|
@ -183,7 +188,12 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
|
|||
}
|
||||
|
||||
const ast = parser.parse(contents);
|
||||
const query = await getQueryForFile(filepath, TSQueryType.CodeSnippets);
|
||||
|
||||
const language = getFullLanguageName(filepath);
|
||||
const query = await getQueryForFile(
|
||||
filepath,
|
||||
`code-snippet-queries/${language}.scm`,
|
||||
);
|
||||
const matches = query?.matches(ast.rootNode);
|
||||
|
||||
if (!matches) {
|
||||
|
|
@ -386,7 +396,9 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
|
|||
const db = await SqliteDb.get();
|
||||
await CodeSnippetsCodebaseIndex._createTables(db);
|
||||
|
||||
const likePatterns = workspaceDirs.map((dir) => truncateSqliteLikePattern(`${dir}%`));
|
||||
const likePatterns = workspaceDirs.map((dir) =>
|
||||
truncateSqliteLikePattern(`${dir}%`),
|
||||
);
|
||||
const placeholders = likePatterns.map(() => "?").join(" OR path LIKE ");
|
||||
|
||||
const query = `
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ describe("CodebaseIndexer", () => {
|
|||
const abortSignal = abortController.signal;
|
||||
|
||||
const updates = [];
|
||||
for await (const update of codebaseIndexer.refresh(
|
||||
for await (const update of codebaseIndexer.refreshDirs(
|
||||
[TEST_DIR],
|
||||
abortSignal,
|
||||
)) {
|
||||
|
|
@ -98,6 +98,16 @@ describe("CodebaseIndexer", () => {
|
|||
return updates;
|
||||
}
|
||||
|
||||
async function refreshIndexFiles(files: string[]) {
|
||||
const updates = [];
|
||||
for await (const update of codebaseIndexer.refreshFiles(
|
||||
files,
|
||||
)) {
|
||||
updates.push(update);
|
||||
}
|
||||
return updates;
|
||||
}
|
||||
|
||||
async function getAllIndexedFiles() {
|
||||
const files = await testIndex.getIndexedFilesForTags(
|
||||
await testIde.getTags(testIndex.artifactId),
|
||||
|
|
@ -158,6 +168,15 @@ describe("CodebaseIndexer", () => {
|
|||
expect(indexed.some((file) => file.endsWith("main.py"))).toBe(true);
|
||||
});
|
||||
|
||||
test("should successfuly re-index specific files", async () => {
|
||||
// Could add more specific tests for this but uses similar logic
|
||||
const before = await getAllIndexedFiles();
|
||||
await refreshIndexFiles(before);
|
||||
|
||||
const after = await getAllIndexedFiles();
|
||||
expect(after.length).toBe(before.length);
|
||||
});
|
||||
|
||||
test("should successfully re-index after adding a file", async () => {
|
||||
addToTestDir([["main.rs", TEST_RS]]);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import {
|
|||
RefreshIndexResults,
|
||||
} from "./types.js";
|
||||
import { walkDirAsync } from "./walkDir.js";
|
||||
import { getBasename } from "../util/index.js";
|
||||
|
||||
export class PauseToken {
|
||||
constructor(private _paused: boolean) {}
|
||||
|
|
@ -144,13 +145,52 @@ export class CodebaseIndexer {
|
|||
}
|
||||
}
|
||||
|
||||
async *refresh(
|
||||
workspaceDirs: string[],
|
||||
async *refreshFiles(
|
||||
files: string[],
|
||||
): AsyncGenerator<IndexingProgressUpdate> {
|
||||
let progress = 0;
|
||||
if (files.length === 0) {
|
||||
yield {
|
||||
progress: 1,
|
||||
desc: "Indexing Complete",
|
||||
status: "done",
|
||||
};
|
||||
}
|
||||
|
||||
const progressPer = 1 / files.length;
|
||||
try {
|
||||
for (const file of files) {
|
||||
yield {
|
||||
progress,
|
||||
desc: `Indexing file ${file}...`,
|
||||
status: "indexing",
|
||||
};
|
||||
await this.refreshFile(file);
|
||||
|
||||
progress += progressPer;
|
||||
|
||||
if (this.pauseToken.paused) {
|
||||
yield* this.yieldUpdateAndPause();
|
||||
}
|
||||
}
|
||||
|
||||
yield {
|
||||
progress: 1,
|
||||
desc: "Indexing Complete",
|
||||
status: "done",
|
||||
};
|
||||
} catch (err) {
|
||||
yield this.handleErrorAndGetProgressUpdate(err);
|
||||
}
|
||||
}
|
||||
|
||||
async *refreshDirs(
|
||||
dirs: string[],
|
||||
abortSignal: AbortSignal,
|
||||
): AsyncGenerator<IndexingProgressUpdate> {
|
||||
let progress = 0;
|
||||
|
||||
if (workspaceDirs.length === 0) {
|
||||
if (dirs.length === 0) {
|
||||
yield {
|
||||
progress,
|
||||
desc: "Nothing to index",
|
||||
|
|
@ -175,11 +215,9 @@ export class CodebaseIndexer {
|
|||
};
|
||||
}
|
||||
|
||||
let completedDirs = 0;
|
||||
|
||||
// Wait until Git Extension has loaded to report progress
|
||||
// so we don't appear stuck at 0% while waiting
|
||||
await this.ide.getRepoName(workspaceDirs[0]);
|
||||
await this.ide.getRepoName(dirs[0]);
|
||||
|
||||
yield {
|
||||
progress,
|
||||
|
|
@ -188,16 +226,16 @@ export class CodebaseIndexer {
|
|||
};
|
||||
const beginTime = Date.now();
|
||||
|
||||
for (const directory of workspaceDirs) {
|
||||
for (const directory of dirs) {
|
||||
const dirBasename = await this.basename(directory);
|
||||
yield {
|
||||
progress,
|
||||
desc: `Discovering files in ${dirBasename}...`,
|
||||
status: "indexing",
|
||||
};
|
||||
const workspaceFiles = [];
|
||||
const directoryFiles = [];
|
||||
for await (const p of walkDirAsync(directory, this.ide)) {
|
||||
workspaceFiles.push(p);
|
||||
directoryFiles.push(p);
|
||||
if (abortSignal.aborted) {
|
||||
yield {
|
||||
progress: 1,
|
||||
|
|
@ -218,7 +256,7 @@ export class CodebaseIndexer {
|
|||
try {
|
||||
for await (const updateDesc of this.indexFiles(
|
||||
directory,
|
||||
workspaceFiles,
|
||||
directoryFiles,
|
||||
branch,
|
||||
repoName,
|
||||
)) {
|
||||
|
|
@ -240,7 +278,7 @@ export class CodebaseIndexer {
|
|||
nextLogThreshold += 0.025;
|
||||
this.logProgress(
|
||||
beginTime,
|
||||
Math.floor(workspaceFiles.length * updateDesc.progress),
|
||||
Math.floor(directoryFiles.length * updateDesc.progress),
|
||||
updateDesc.progress,
|
||||
);
|
||||
}
|
||||
|
|
@ -347,18 +385,18 @@ export class CodebaseIndexer {
|
|||
}
|
||||
|
||||
private async *indexFiles(
|
||||
workspaceDir: string,
|
||||
workspaceFiles: string[],
|
||||
directory: string,
|
||||
files: string[],
|
||||
branch: string,
|
||||
repoName: string | undefined,
|
||||
): AsyncGenerator<IndexingProgressUpdate> {
|
||||
const stats = await this.ide.getLastModified(workspaceFiles);
|
||||
const stats = await this.ide.getLastModified(files);
|
||||
const indexesToBuild = await this.getIndexesToBuild();
|
||||
let completedIndexCount = 0;
|
||||
let progress = 0;
|
||||
for (const codebaseIndex of indexesToBuild) {
|
||||
const tag: IndexTag = {
|
||||
directory: workspaceDir,
|
||||
directory,
|
||||
branch,
|
||||
artifactId: codebaseIndex.artifactId,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class DocsCrawler {
|
|||
);
|
||||
|
||||
if (didInstall) {
|
||||
await this.ide.showToast(
|
||||
void this.ide.showToast(
|
||||
"info",
|
||||
`Successfully installed Chromium! Retrying crawl of: ${startUrl.toString()}`,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ export default class DocsService {
|
|||
params: {},
|
||||
});
|
||||
|
||||
await this.ide.showToast(
|
||||
void this.ide.showToast(
|
||||
"info",
|
||||
"Successfuly added docs context provider",
|
||||
);
|
||||
|
|
@ -183,7 +183,7 @@ export default class DocsService {
|
|||
while (!(await generator.next()).done) {}
|
||||
}
|
||||
|
||||
await this.ide.showToast("info", "Docs indexing completed");
|
||||
void this.ide.showToast("info", "Docs indexing completed");
|
||||
}
|
||||
|
||||
async list() {
|
||||
|
|
@ -254,6 +254,8 @@ export default class DocsService {
|
|||
if (processedPages === maxKnownPages) {
|
||||
maxKnownPages *= 2;
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
}
|
||||
|
||||
void Telemetry.capture("docs_pages_crawled", {
|
||||
|
|
@ -741,7 +743,7 @@ export default class DocsService {
|
|||
|
||||
if (isJetBrainsAndPreIndexedDocsProvider) {
|
||||
// A bit noisy for teams users whom have no choice if their admin is the one who didn't setup an embeddingsProvider
|
||||
// this.ide.showToast(
|
||||
// void this.ide.showToast(
|
||||
// "error",
|
||||
// "The 'transformers.js' embeddings provider currently cannot be used to index " +
|
||||
// "documentation in JetBrains. To enable documentation indexing, you can use " +
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ export class ChromiumInstaller {
|
|||
|
||||
ChromiumCrawler.setUseChromiumForDocsCrawling(false);
|
||||
|
||||
await this.ide.showToast("error", "Failed to install Chromium");
|
||||
void this.ide.showToast("error", "Failed to install Chromium");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ const PROVIDER_HANDLES_TEMPLATING: ModelProvider[] = [
|
|||
"mistral",
|
||||
"sambanova",
|
||||
"vertexai",
|
||||
"watsonx"
|
||||
"watsonx",
|
||||
];
|
||||
|
||||
const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [
|
||||
|
|
@ -63,7 +63,8 @@ const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [
|
|||
"sagemaker",
|
||||
"continue-proxy",
|
||||
"openrouter",
|
||||
"vertexai"
|
||||
"vertexai",
|
||||
"azure",
|
||||
];
|
||||
|
||||
const MODEL_SUPPORTS_IMAGES: string[] = [
|
||||
|
|
@ -121,7 +122,7 @@ const PARALLEL_PROVIDERS: ModelProvider[] = [
|
|||
"together",
|
||||
"sambanova",
|
||||
"nebius",
|
||||
"vertexai"
|
||||
"vertexai",
|
||||
];
|
||||
|
||||
function llmCanGenerateInParallel(
|
||||
|
|
|
|||
|
|
@ -323,6 +323,27 @@ function pruneChatHistory(
|
|||
return chatHistory;
|
||||
}
|
||||
|
||||
function messageIsEmpty(message: ChatMessage): boolean {
|
||||
if (typeof message.content === "string") {
|
||||
return message.content.trim() === "";
|
||||
}
|
||||
if (Array.isArray(message.content)) {
|
||||
return message.content.every(
|
||||
(item) => !item.imageUrl && item.text?.trim() === "",
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function addSpaceToAnyEmptyMessages(messages: ChatMessage[]): ChatMessage[] {
|
||||
return messages.map((message) => {
|
||||
if (messageIsEmpty(message)) {
|
||||
message.content = " ";
|
||||
}
|
||||
return message;
|
||||
});
|
||||
}
|
||||
|
||||
function compileChatMessages(
|
||||
modelName: string,
|
||||
msgs: ChatMessage[] | undefined,
|
||||
|
|
@ -333,12 +354,14 @@ function compileChatMessages(
|
|||
functions: any[] | undefined = undefined,
|
||||
systemMessage: string | undefined = undefined,
|
||||
): ChatMessage[] {
|
||||
const msgsCopy = msgs
|
||||
let msgsCopy = msgs
|
||||
? msgs
|
||||
.map((msg) => ({ ...msg }))
|
||||
.filter((msg) => msg.content !== "" && msg.role !== "system")
|
||||
: [];
|
||||
|
||||
msgsCopy = addSpaceToAnyEmptyMessages(msgsCopy);
|
||||
|
||||
if (prompt) {
|
||||
const promptMsg: ChatMessage = {
|
||||
role: "user",
|
||||
|
|
|
|||
|
|
@ -13,13 +13,14 @@ class ContinueProxy extends OpenAI {
|
|||
static providerName: ModelProvider = "continue-proxy";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
useLegacyCompletionsEndpoint: false,
|
||||
requestOptions: {
|
||||
headers: {
|
||||
"x-continue-unique-id": Telemetry.uniqueId,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
protected _getHeaders() {
|
||||
const headers: any = super._getHeaders();
|
||||
headers["x-continue-unique-id"] = Telemetry.uniqueId;
|
||||
return headers;
|
||||
}
|
||||
|
||||
supportsCompletions(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
95
core/package-lock.json
generated
95
core/package-lock.json
generated
|
|
@ -101,12 +101,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@75lb/deep-merge": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.1.tgz",
|
||||
"integrity": "sha512-xvgv6pkMGBA6GwdyJbNAnDmfAIR/DfWhrj9jgWh3TY7gRm3KO46x/GPjRg6wJ0nOepwqrNxFfojebh0Df4h4Tw==",
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.2.tgz",
|
||||
"integrity": "sha512-08K9ou5VNbheZFxM5tDWoqjA3ImC50DiuuJ2tj1yEPRfkp8lLLg6XAaJ4On+a0yAXor/8ay5gHnAIshRM44Kpw==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"lodash.assignwith": "^4.2.0",
|
||||
"lodash": "^4.17.21",
|
||||
"typical": "^7.1.1"
|
||||
},
|
||||
"engines": {
|
||||
|
|
@ -5832,15 +5832,23 @@
|
|||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/aws-ssl-profiles": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz",
|
||||
"integrity": "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==",
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/aws4": {
|
||||
"version": "1.13.0",
|
||||
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.0.tgz",
|
||||
"integrity": "sha512-3AungXC4I8kKsS9PuS4JH2nc+0bVY/mjgrephHTIi8fpEeGsTHBUJeosp0Wc1myYMElmD0B3Oc4XL/HVJ4PV2g=="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.1.tgz",
|
||||
"integrity": "sha512-+LV37nQcd1EpFalkXksWNBiA17NZ5m5/WspmHGmZmdx1qBOg/VNq/c4eRJiA9VQQHBOs+N0ZhhdU10h2TyNK7Q==",
|
||||
"version": "1.7.7",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz",
|
||||
"integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
"form-data": "^4.0.0",
|
||||
|
|
@ -7331,27 +7339,27 @@
|
|||
}
|
||||
},
|
||||
"node_modules/engine.io-client": {
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz",
|
||||
"integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==",
|
||||
"version": "6.5.4",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.4.tgz",
|
||||
"integrity": "sha512-GeZeeRjpD2qf49cZQ0Wvh/8NJNfeXkXXcoGh+F77oEAgo9gUHwT1fCRxSNU+YEEaysOJTnsFHmM5oAcPy4ntvQ==",
|
||||
"dependencies": {
|
||||
"@socket.io/component-emitter": "~3.1.0",
|
||||
"debug": "~4.3.1",
|
||||
"engine.io-parser": "~5.2.1",
|
||||
"ws": "~8.11.0",
|
||||
"ws": "~8.17.1",
|
||||
"xmlhttprequest-ssl": "~2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-client/node_modules/ws": {
|
||||
"version": "8.11.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
|
||||
"integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
|
||||
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": "^5.0.2"
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
|
|
@ -10868,12 +10876,6 @@
|
|||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
},
|
||||
"node_modules/lodash.assignwith": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz",
|
||||
"integrity": "sha512-ZznplvbvtjK2gMvnQ1BR/zqPFZmS6jbK4p+6Up4xcRYA7yMIwxHCfbTcrYxXKzzqLsQ05eJPVznEW3tuwV7k1g==",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/lodash.camelcase": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
|
||||
|
|
@ -10910,6 +10912,20 @@
|
|||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/lru.min": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.1.tgz",
|
||||
"integrity": "sha512-FbAj6lXil6t8z4z3j0E5mfRlPzxkySotzUHwRXjlpRh10vc6AI6WN62ehZj82VG7M20rqogJ0GLwar2Xa05a8Q==",
|
||||
"engines": {
|
||||
"bun": ">=1.0.0",
|
||||
"deno": ">=1.30.0",
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wellwelwel"
|
||||
}
|
||||
},
|
||||
"node_modules/mac-ca": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mac-ca/-/mac-ca-3.1.0.tgz",
|
||||
|
|
@ -11068,28 +11084,17 @@
|
|||
}
|
||||
},
|
||||
"node_modules/micromatch": {
|
||||
"version": "4.0.6",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.6.tgz",
|
||||
"integrity": "sha512-Y4Ypn3oujJYxJcMacVgcs92wofTHxp9FzfDpQON4msDefoC0lb3ETvQLOdLcbhSwU1bz8HrL/1sygfBIHudrkQ==",
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||
"dependencies": {
|
||||
"braces": "^3.0.3",
|
||||
"picomatch": "^4.0.2"
|
||||
"picomatch": "^2.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.6"
|
||||
}
|
||||
},
|
||||
"node_modules/micromatch/node_modules/picomatch": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz",
|
||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
|
|
@ -11293,15 +11298,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/mysql2": {
|
||||
"version": "3.9.7",
|
||||
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.9.7.tgz",
|
||||
"integrity": "sha512-KnJT8vYRcNAZv73uf9zpXqNbvBG7DJrs+1nACsjZP1HMJ1TgXEy8wnNilXAn/5i57JizXKtrUtwDB7HxT9DDpw==",
|
||||
"version": "3.11.4",
|
||||
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.11.4.tgz",
|
||||
"integrity": "sha512-Z2o3tY4Z8EvSRDwknaC40MdZ3+m0sKbpnXrShQLdxPrAvcNli7jLrD2Zd2IzsRMw4eK9Yle500FDmlkIqp+krg==",
|
||||
"dependencies": {
|
||||
"aws-ssl-profiles": "^1.1.1",
|
||||
"denque": "^2.1.0",
|
||||
"generate-function": "^2.3.1",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"long": "^5.2.1",
|
||||
"lru-cache": "^8.0.0",
|
||||
"lru.min": "^1.0.0",
|
||||
"named-placeholders": "^1.1.3",
|
||||
"seq-queue": "^0.0.5",
|
||||
"sqlstring": "^2.3.2"
|
||||
|
|
@ -11310,14 +11316,6 @@
|
|||
"node": ">= 8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/mysql2/node_modules/lru-cache": {
|
||||
"version": "8.0.5",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-8.0.5.tgz",
|
||||
"integrity": "sha512-MhWWlVnuab1RG5/zMRRcVGXZLCXrZTgfwMikgzCegsPnG62yDQo5JnqKkrK4jO5iKqDAZGItAqN5CtKBCBWRUA==",
|
||||
"engines": {
|
||||
"node": ">=16.14"
|
||||
}
|
||||
},
|
||||
"node_modules/named-placeholders": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.3.tgz",
|
||||
|
|
@ -12253,7 +12251,6 @@
|
|||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8.6"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,46 +1,39 @@
|
|||
import path from "path";
|
||||
|
||||
import { IDE } from "../..";
|
||||
import { GlobalContext } from "../../util/GlobalContext";
|
||||
|
||||
import { DEFAULT_PROMPTS_FOLDER_V2 } from "./getPromptFiles";
|
||||
import { getPathModuleForIde } from "../../util/pathModule";
|
||||
|
||||
const FIRST_TIME_DEFAULT_PROMPT_FILE = `# This is an example ".prompt" file
|
||||
# It is used to define and reuse prompts within Continue
|
||||
# Continue will automatically create a context provider for each prompt in the .prompts folder
|
||||
# Each .prompt file can be accessed by typing "@prompts" in the Chat input
|
||||
|
||||
# A prompt file consists of two parts:
|
||||
# 1. Everything above the "---" is YAML. Here you can set "temperature", "description", and other options
|
||||
# 2. Everything below the "---" is the prompt body
|
||||
|
||||
# If you don't want to set any options, you don't need to include the "---"
|
||||
# If you do not want to set any options, you do not need to include the "---"
|
||||
|
||||
# In the body, you can reference:
|
||||
# 1. Files, using either absolute or relative (based on the workspace root) paths
|
||||
# e.g. @README.md
|
||||
# e.g. @src/test/test.py
|
||||
# e.g. @/Users/me/Desktop/my-project/src/test/test.py
|
||||
# 2. URLs
|
||||
# e.g. https://example.com
|
||||
# 3. Some context providers, like
|
||||
# e.g. @currentFile
|
||||
# e.g. @os
|
||||
# e.g. @repo-map
|
||||
# 1. Files, using either absolute or relative paths (based on the workspace root)
|
||||
# @README.md
|
||||
# @src/test/test.py
|
||||
# @/Users/me/Desktop/my-project/src/test/test.py
|
||||
# 2. URLs, for example
|
||||
# @https://example.com
|
||||
# 3. Context providers, for example
|
||||
# @currentFile
|
||||
# @os
|
||||
# @repo-map
|
||||
|
||||
# To learn more, see the full .prompt file reference: https://docs.continue.dev/features/prompt-files
|
||||
name: Example
|
||||
description: Example prompt file
|
||||
version: 2
|
||||
---
|
||||
@README.md
|
||||
|
||||
Please reference the above README.md file to understand the current project.
|
||||
`;
|
||||
|
||||
const DEFAULT_PROMPT_FILE = `version: 2
|
||||
---
|
||||
|
||||
`;
|
||||
Here is information about the current repo:
|
||||
|
||||
@README.md`;
|
||||
|
||||
const DEFAULT_PROMPT_FILE = "";
|
||||
|
||||
export async function createNewPromptFileV2(
|
||||
ide: IDE,
|
||||
|
|
@ -52,9 +45,11 @@ export async function createNewPromptFileV2(
|
|||
"No workspace directories found. Make sure you've opened a folder in your IDE.",
|
||||
);
|
||||
}
|
||||
const baseDir = path.join(
|
||||
const pathModule = await getPathModuleForIde(ide);
|
||||
|
||||
const baseDir = pathModule.join(
|
||||
workspaceDirs[0],
|
||||
promptPath ?? DEFAULT_PROMPTS_FOLDER_V2,
|
||||
promptPath ?? pathModule.join(".continue", "prompts"),
|
||||
);
|
||||
|
||||
// Find the first available filename
|
||||
|
|
@ -62,7 +57,10 @@ export async function createNewPromptFileV2(
|
|||
let promptFilePath: string;
|
||||
do {
|
||||
const suffix = counter === 0 ? "" : `-${counter}`;
|
||||
promptFilePath = path.join(baseDir, `new-prompt-file${suffix}.prompt`);
|
||||
promptFilePath = pathModule.join(
|
||||
baseDir,
|
||||
`new-prompt-file${suffix}.prompt`,
|
||||
);
|
||||
counter++;
|
||||
} while (await ide.fileExists(promptFilePath));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import path from "path";
|
||||
|
||||
import { IDE } from "../..";
|
||||
import { walkDir } from "../../indexing/walkDir";
|
||||
import { getPathModuleForIde } from "../../util/pathModule";
|
||||
import { readAllGlobalPromptFiles } from "../../util/paths";
|
||||
|
||||
async function getPromptFilesFromDir(
|
||||
|
|
@ -27,20 +26,23 @@ async function getPromptFilesFromDir(
|
|||
}
|
||||
}
|
||||
|
||||
export const DEFAULT_PROMPTS_FOLDER_V2 = ".prompts";
|
||||
|
||||
export async function getAllPromptFilesV2(
|
||||
ide: IDE,
|
||||
overridePromptFolder?: string,
|
||||
): Promise<{ path: string; content: string }[]> {
|
||||
const workspaceDirs = await ide.getWorkspaceDirs();
|
||||
let promptFiles: { path: string; content: string }[] = [];
|
||||
const pathModule = await getPathModuleForIde(ide);
|
||||
|
||||
promptFiles = (
|
||||
await Promise.all(
|
||||
workspaceDirs.map((dir) =>
|
||||
getPromptFilesFromDir(
|
||||
ide,
|
||||
path.join(dir, overridePromptFolder ?? DEFAULT_PROMPTS_FOLDER_V2),
|
||||
pathModule.join(
|
||||
dir,
|
||||
overridePromptFolder ?? pathModule.join(".continue", "prompts"),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ContextItem, ContextProviderExtras } from "../..";
|
||||
import { contextProviderClassFromName } from "../../context/providers";
|
||||
import URLContextProvider from "../../context/providers/URLContextProvider";
|
||||
import { getBasename } from "../../util";
|
||||
|
||||
import { getPreambleAndBody } from "./parse";
|
||||
|
||||
async function resolveAttachment(
|
||||
|
|
@ -15,6 +15,13 @@ async function resolveAttachment(
|
|||
if (contextProvider) {
|
||||
const items = await contextProvider.getContextItems("", extras);
|
||||
return items;
|
||||
} else {
|
||||
// Just instantiate it here
|
||||
const providerClass = contextProviderClassFromName(name) as any;
|
||||
if (providerClass) {
|
||||
const providerInstance = new providerClass({});
|
||||
return providerInstance.getContextItems("", extras);
|
||||
}
|
||||
}
|
||||
|
||||
// Files
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
undefined | { dirs?: string[]; shouldClearIndexes?: boolean },
|
||||
void,
|
||||
];
|
||||
"index/forceReIndexFiles": [undefined | { files?: string[] }, void];
|
||||
"index/indexingProgressBarInitialized": [undefined, void];
|
||||
completeOnboarding: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
|
|||
insertAtCursor: [{ text: string }, void];
|
||||
copyText: [{ text: string }, void];
|
||||
"jetbrains/editorInsetHeight": [{ height: number }, void];
|
||||
"jetbrains/isOSREnabled": [undefined, void];
|
||||
"vscode/openMoveRightMarkdown": [undefined, void];
|
||||
setGitHubAuthToken: [{ token: string }, void];
|
||||
acceptDiff: [{ filepath: string }, void];
|
||||
|
|
@ -103,6 +104,7 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
|||
setTheme: [{ theme: any }, void];
|
||||
setColors: [{ [key: string]: string }, void];
|
||||
"jetbrains/editorInsetRefresh": [undefined, void];
|
||||
"jetbrains/isOSREnabled": [boolean, void];
|
||||
addApiKey: [undefined, void];
|
||||
setupLocalConfig: [undefined, void];
|
||||
incrementFtc: [undefined, void];
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"stats/getTokensPerModel",
|
||||
"index/setPaused",
|
||||
"index/forceReIndex",
|
||||
"index/forceReIndexFiles",
|
||||
"index/indexingProgressBarInitialized",
|
||||
"completeOnboarding",
|
||||
"addAutocompleteModel",
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import { GetGhTokenArgs } from "../protocol/ide.js";
|
|||
import { getContinueGlobalPath } from "./paths.js";
|
||||
|
||||
class FileSystemIde implements IDE {
|
||||
constructor(private readonly workspaceDir: string) { }
|
||||
constructor(private readonly workspaceDir: string) {}
|
||||
showToast(
|
||||
type: ToastType,
|
||||
message: string,
|
||||
|
|
@ -36,7 +36,7 @@ class FileSystemIde implements IDE {
|
|||
}
|
||||
|
||||
gotoDefinition(location: Location): Promise<RangeInFile[]> {
|
||||
throw new Error("Method not implemented.");
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
onDidChangeActiveTextEditor(callback: (filepath: string) => void): void {
|
||||
return;
|
||||
|
|
|
|||
13
core/util/pathModule.ts
Normal file
13
core/util/pathModule.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { PlatformPath, posix, win32 } from "node:path";
|
||||
import { IDE } from "..";
|
||||
|
||||
export type PathSep = "/" | "\\";
|
||||
|
||||
function getPathModuleFromPathSep(pathSep: PathSep): PlatformPath {
|
||||
return pathSep === "/" ? posix : win32;
|
||||
}
|
||||
|
||||
export async function getPathModuleForIde(ide: IDE): Promise<PlatformPath> {
|
||||
const pathSep = await ide.pathSep();
|
||||
return getPathModuleFromPathSep(pathSep as PathSep);
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ export function getPromptLogsPath(): string {
|
|||
}
|
||||
|
||||
export function getGlobalPromptsPath(): string {
|
||||
return path.join(getContinueGlobalPath(), ".prompts");
|
||||
return path.join(getContinueGlobalPath(), "prompts");
|
||||
}
|
||||
|
||||
export function readAllGlobalPromptFiles(
|
||||
|
|
|
|||
|
|
@ -2,84 +2,118 @@ import fs from "node:fs";
|
|||
import * as path from "node:path";
|
||||
|
||||
import Parser, { Language } from "web-tree-sitter";
|
||||
|
||||
import { FileSymbolMap, IDE, SymbolWithRange } from "..";
|
||||
|
||||
export const supportedLanguages: { [key: string]: string } = {
|
||||
cpp: "cpp",
|
||||
hpp: "cpp",
|
||||
cc: "cpp",
|
||||
cxx: "cpp",
|
||||
hxx: "cpp",
|
||||
cp: "cpp",
|
||||
hh: "cpp",
|
||||
inc: "cpp",
|
||||
// Depended on this PR: https://github.com/tree-sitter/tree-sitter-cpp/pull/173
|
||||
// ccm: "cpp",
|
||||
// c++m: "cpp",
|
||||
// cppm: "cpp",
|
||||
// cxxm: "cpp",
|
||||
cs: "c_sharp",
|
||||
c: "c",
|
||||
h: "c",
|
||||
css: "css",
|
||||
php: "php",
|
||||
phtml: "php",
|
||||
php3: "php",
|
||||
php4: "php",
|
||||
php5: "php",
|
||||
php7: "php",
|
||||
phps: "php",
|
||||
"php-s": "php",
|
||||
bash: "bash",
|
||||
sh: "bash",
|
||||
json: "json",
|
||||
ts: "typescript",
|
||||
mts: "typescript",
|
||||
cts: "typescript",
|
||||
tsx: "tsx",
|
||||
// vue: "vue", // tree-sitter-vue parser is broken
|
||||
// The .wasm file being used is faulty, and yaml is split line-by-line anyway for the most part
|
||||
// yaml: "yaml",
|
||||
// yml: "yaml",
|
||||
elm: "elm",
|
||||
js: "javascript",
|
||||
jsx: "javascript",
|
||||
mjs: "javascript",
|
||||
cjs: "javascript",
|
||||
py: "python",
|
||||
ipynb: "python",
|
||||
pyw: "python",
|
||||
pyi: "python",
|
||||
el: "elisp",
|
||||
emacs: "elisp",
|
||||
ex: "elixir",
|
||||
exs: "elixir",
|
||||
go: "go",
|
||||
eex: "embedded_template",
|
||||
heex: "embedded_template",
|
||||
leex: "embedded_template",
|
||||
html: "html",
|
||||
htm: "html",
|
||||
java: "java",
|
||||
lua: "lua",
|
||||
ocaml: "ocaml",
|
||||
ml: "ocaml",
|
||||
mli: "ocaml",
|
||||
ql: "ql",
|
||||
res: "rescript",
|
||||
resi: "rescript",
|
||||
rb: "ruby",
|
||||
erb: "ruby",
|
||||
rs: "rust",
|
||||
rdl: "systemrdl",
|
||||
toml: "toml",
|
||||
sol: "solidity",
|
||||
export enum LanguageName {
|
||||
CPP = "cpp",
|
||||
C_SHARP = "c_sharp",
|
||||
C = "c",
|
||||
CSS = "css",
|
||||
PHP = "php",
|
||||
BASH = "bash",
|
||||
JSON = "json",
|
||||
TYPESCRIPT = "typescript",
|
||||
TSX = "tsx",
|
||||
ELM = "elm",
|
||||
JAVASCRIPT = "javascript",
|
||||
PYTHON = "python",
|
||||
ELISP = "elisp",
|
||||
ELIXIR = "elixir",
|
||||
GO = "go",
|
||||
EMBEDDED_TEMPLATE = "embedded_template",
|
||||
HTML = "html",
|
||||
JAVA = "java",
|
||||
LUA = "lua",
|
||||
OCAML = "ocaml",
|
||||
QL = "ql",
|
||||
RESCRIPT = "rescript",
|
||||
RUBY = "ruby",
|
||||
RUST = "rust",
|
||||
SYSTEMRDL = "systemrdl",
|
||||
TOML = "toml",
|
||||
SOLIDITY = "solidity",
|
||||
}
|
||||
|
||||
// jl: "julia",
|
||||
// swift: "swift",
|
||||
// kt: "kotlin",
|
||||
// scala: "scala",
|
||||
export const supportedLanguages: { [key: string]: LanguageName } = {
|
||||
cpp: LanguageName.CPP,
|
||||
hpp: LanguageName.CPP,
|
||||
cc: LanguageName.CPP,
|
||||
cxx: LanguageName.CPP,
|
||||
hxx: LanguageName.CPP,
|
||||
cp: LanguageName.CPP,
|
||||
hh: LanguageName.CPP,
|
||||
inc: LanguageName.CPP,
|
||||
// Depended on this PR: https://github.com/tree-sitter/tree-sitter-cpp/pull/173
|
||||
// ccm: LanguageName.CPP,
|
||||
// c++m: LanguageName.CPP,
|
||||
// cppm: LanguageName.CPP,
|
||||
// cxxm: LanguageName.CPP,
|
||||
cs: LanguageName.C_SHARP,
|
||||
c: LanguageName.C,
|
||||
h: LanguageName.C,
|
||||
css: LanguageName.CSS,
|
||||
php: LanguageName.PHP,
|
||||
phtml: LanguageName.PHP,
|
||||
php3: LanguageName.PHP,
|
||||
php4: LanguageName.PHP,
|
||||
php5: LanguageName.PHP,
|
||||
php7: LanguageName.PHP,
|
||||
phps: LanguageName.PHP,
|
||||
"php-s": LanguageName.PHP,
|
||||
bash: LanguageName.BASH,
|
||||
sh: LanguageName.BASH,
|
||||
json: LanguageName.JSON,
|
||||
ts: LanguageName.TYPESCRIPT,
|
||||
mts: LanguageName.TYPESCRIPT,
|
||||
cts: LanguageName.TYPESCRIPT,
|
||||
tsx: LanguageName.TSX,
|
||||
// vue: LanguageName.VUE, // tree-sitter-vue parser is broken
|
||||
// The .wasm file being used is faulty, and yaml is split line-by-line anyway for the most part
|
||||
// yaml: LanguageName.YAML,
|
||||
// yml: LanguageName.YAML,
|
||||
elm: LanguageName.ELM,
|
||||
js: LanguageName.JAVASCRIPT,
|
||||
jsx: LanguageName.JAVASCRIPT,
|
||||
mjs: LanguageName.JAVASCRIPT,
|
||||
cjs: LanguageName.JAVASCRIPT,
|
||||
py: LanguageName.PYTHON,
|
||||
ipynb: LanguageName.PYTHON,
|
||||
pyw: LanguageName.PYTHON,
|
||||
pyi: LanguageName.PYTHON,
|
||||
el: LanguageName.ELISP,
|
||||
emacs: LanguageName.ELISP,
|
||||
ex: LanguageName.ELIXIR,
|
||||
exs: LanguageName.ELIXIR,
|
||||
go: LanguageName.GO,
|
||||
eex: LanguageName.EMBEDDED_TEMPLATE,
|
||||
heex: LanguageName.EMBEDDED_TEMPLATE,
|
||||
leex: LanguageName.EMBEDDED_TEMPLATE,
|
||||
html: LanguageName.HTML,
|
||||
htm: LanguageName.HTML,
|
||||
java: LanguageName.JAVA,
|
||||
lua: LanguageName.LUA,
|
||||
ocaml: LanguageName.OCAML,
|
||||
ml: LanguageName.OCAML,
|
||||
mli: LanguageName.OCAML,
|
||||
ql: LanguageName.QL,
|
||||
res: LanguageName.RESCRIPT,
|
||||
resi: LanguageName.RESCRIPT,
|
||||
rb: LanguageName.RUBY,
|
||||
erb: LanguageName.RUBY,
|
||||
rs: LanguageName.RUST,
|
||||
rdl: LanguageName.SYSTEMRDL,
|
||||
toml: LanguageName.TOML,
|
||||
sol: LanguageName.SOLIDITY,
|
||||
|
||||
// jl: LanguageName.JULIA,
|
||||
// swift: LanguageName.SWIFT,
|
||||
// kt: LanguageName.KOTLIN,
|
||||
// scala: LanguageName.SCALA,
|
||||
};
|
||||
|
||||
export const IGNORE_PATH_PATTERNS: Partial<Record<LanguageName, RegExp[]>> = {
|
||||
[LanguageName.TYPESCRIPT]: [/.*node_modules/],
|
||||
[LanguageName.JAVASCRIPT]: [/.*node_modules/],
|
||||
};
|
||||
|
||||
export async function getParserForFile(filepath: string) {
|
||||
|
|
@ -130,15 +164,9 @@ export async function getLanguageForFile(
|
|||
}
|
||||
}
|
||||
|
||||
export enum TSQueryType {
|
||||
CodeSnippets = "code-snippet-queries",
|
||||
Imports = "import-queries",
|
||||
// Used in RootPathContextService.ts
|
||||
FunctionDeclaration = "root-path-context-queries/function_declaration",
|
||||
MethodDefinition = "root-path-context-queries/method_definition",
|
||||
FunctionDefinition = "root-path-context-queries/function_definition",
|
||||
MethodDeclaration = "root-path-context-queries/method_declaration",
|
||||
}
|
||||
export const getFullLanguageName = (filepath: string) => {
|
||||
return supportedLanguages[filepath.split(".").pop() ?? ""];
|
||||
};
|
||||
|
||||
export async function getQueryForFile(
|
||||
filepath: string,
|
||||
|
|
@ -149,7 +177,6 @@ export async function getQueryForFile(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const fullLangName = supportedLanguages[filepath.split(".").pop() ?? ""];
|
||||
const sourcePath = path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
|
|
@ -157,7 +184,6 @@ export async function getQueryForFile(
|
|||
? ["extensions", "vscode", "tree-sitter"]
|
||||
: ["tree-sitter"]),
|
||||
queryPath,
|
||||
`${fullLangName}.scm`,
|
||||
);
|
||||
if (!fs.existsSync(sourcePath)) {
|
||||
return undefined;
|
||||
|
|
@ -218,7 +244,7 @@ export async function getSymbolsForFile(
|
|||
// console.log(`child: ${child.type}, ${child.text}`);
|
||||
// });
|
||||
|
||||
// Empirically, the actualy name is the last identifier in the node
|
||||
// Empirically, the actual name is the last identifier in the node
|
||||
// Especially with languages where return type is declared before the name
|
||||
// TODO use findLast in newer version of node target
|
||||
let identifier: Parser.SyntaxNode | undefined = undefined;
|
||||
|
|
|
|||
|
|
@ -82,10 +82,10 @@ export class TTS {
|
|||
return;
|
||||
}
|
||||
|
||||
TTS.messenger.request("setTTSActive", true);
|
||||
void TTS.messenger.request("setTTSActive", true);
|
||||
|
||||
TTS.handle?.once("exit", () => {
|
||||
TTS.messenger.request("setTTSActive", false);
|
||||
void TTS.messenger.request("setTTSActive", false);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ sidebar_position: 5
|
|||
|
||||
There are a number of different ways to customize Chat
|
||||
|
||||
- You can add a [`.continuerules`](../customize/deep-dives/rules.md) file to the root of your project to customize the system prompt
|
||||
- You can configure [`@Codebase`](../customize/deep-dives/codebase.md)
|
||||
- You can create your own [custom code RAG](../customize/tutorials/custom-code-rag.md)
|
||||
- You can configure [`@Docs`](../customize/deep-dives/docs.md)
|
||||
|
|
|
|||
|
|
@ -6,42 +6,30 @@ Prompt files provide a convenient way to standardize common patterns and share a
|
|||
|
||||
## Quick start
|
||||
|
||||
:::tip[Prompt library]
|
||||
<!-- :::tip[Prompt library]
|
||||
To assist you in getting started, [we've curated a small library of `.prompt` files](https://github.com/continuedev/prompt-file-examples). We encourage community contributions to this repository, so please consider opening up a pull request with your own prompts!
|
||||
:::
|
||||
::: -->
|
||||
|
||||
Below is a quick example of setting up a prompt file to write unit tests using Jest.
|
||||
Below is a quick example of setting up a prompt file to de
|
||||
|
||||
1. Create a folder called `.prompts/` at the top level of your workspace.
|
||||
2. Add a file called `test.prompt` to this folder. The name of this file will be the name of the slash command you will use to generate your prompt.
|
||||
3. Write the following contents to `test.prompt` and save.
|
||||
1. Create a folder called `.continue/prompts` at the top level of your workspace (or you can use the button in the UI by typing @, selecting "Prompt Files", and selecting "New Prompt File").
|
||||
2. Add a file called `rails.prompt` to this folder.
|
||||
3. Write the following contents to `rails.prompt` and save.
|
||||
|
||||
```
|
||||
temperature: 0.5
|
||||
maxTokens: 4096
|
||||
name: Rails Project
|
||||
description: Information about this project
|
||||
---
|
||||
<system>
|
||||
You are an expert programmer
|
||||
</system>
|
||||
|
||||
{{{ input }}}
|
||||
|
||||
Write unit tests for the above selected code, following each of these instructions:
|
||||
- Use `jest`
|
||||
- Properly set up and tear down
|
||||
- Include important edge cases
|
||||
- The tests should be complete and sophisticated
|
||||
- Give the tests just as chat output, don't edit any file
|
||||
- Don't explain how to set up `jest`
|
||||
Attached is a summary of the current Ruby on Rails application, including the @Gemfile and database schema in @db/schema.rb
|
||||
```
|
||||
|
||||
Now to use this prompt, you can highlight code and use <kbd>cmd/ctrl</kbd> + <kbd>L</kbd> to select it in the Continue sidebar.
|
||||
|
||||
Then, type "/" to see the list of slash commands and choose the one called "test". Press enter and the LLM will respond given the instructions from your prompt file.
|
||||
Then, type "@", select "Prompt files", and choose the one called "Rails Project". You can now ask any question as usual and the LLM will have the information from your .prompt file.
|
||||
|
||||
## Format
|
||||
|
||||
The format is inspired by [HumanLoops's .prompt file](https://docs.humanloop.com/docs/prompt-file-format), with additional templating to use context providers and built-in variables using [Handlebars syntax](https://handlebarsjs.com/guide/).
|
||||
The format is inspired by [HumanLoops's .prompt file](https://docs.humanloop.com/docs/prompt-file-format), with additional templating to reference files, URLs, and context providers.
|
||||
|
||||
:::info
|
||||
The current state of this format is experimental and subject to change
|
||||
|
|
@ -51,38 +39,19 @@ The current state of this format is experimental and subject to change
|
|||
|
||||
The "preamble" is everything above the `---` separator, and lets you specify model parameters. It uses YAML syntax and currently supports the following parameters:
|
||||
|
||||
- `name`
|
||||
- `temperature`
|
||||
- `topP`
|
||||
- `topK`
|
||||
- `minP`
|
||||
- `presencePenalty`
|
||||
- `frequencyPenalty`
|
||||
- `mirostat`
|
||||
- `stop`
|
||||
- `maxTokens`
|
||||
- `description`
|
||||
- `name` - The display title
|
||||
- `description` - The description you will see in the dropdown
|
||||
- `version` - Can be either "1" (for legacy prompt files) or "2" (this is the default and does not need to be set)
|
||||
|
||||
If you don't need any of these parameters, you can leave out the preamble and do not need to include the `---` separator.
|
||||
|
||||
### System message
|
||||
### Context
|
||||
|
||||
To add a system message, start the body with `<system></system>` tags like in the example above and place your system message inside.
|
||||
Many [context provider](../context-providers.md) can be referenced by typing "@" followed by the name of the context provider.
|
||||
|
||||
### Built-in variables
|
||||
|
||||
The following built-in variables are currently available:
|
||||
|
||||
- `{{{ input }}}` - The full text from the input box in the sidebar that is sent along with the slash command
|
||||
- `{{{ currentFile }}}` - The currently open file in your IDE
|
||||
- `{{{ ./path/to/file.js }}}` - Any file can be directly referenced
|
||||
|
||||
### Context providers
|
||||
|
||||
Any [context provider](../context-providers.md) that you have added to your config can be referenced using the name of the context provider. Context providers that receive an input are also supported.
|
||||
|
||||
- `{{{ terminal }}}` - The contents of the terminal
|
||||
- `{{{ url "https://github.com/continuedev/continue" }}}` - The contents of a URL
|
||||
- `@terminal` - The contents of the terminal
|
||||
- `@https://github.com/continuedev/continue` - The contents of a URL
|
||||
- `@src/index.ts` - The contents of a file
|
||||
|
||||
## Feedback
|
||||
|
||||
|
|
|
|||
27
docs/docs/customize/deep-dives/rules.md
Normal file
27
docs/docs/customize/deep-dives/rules.md
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
description: Learn how to customize the system prompt with a `.continuerules` file
|
||||
keywords: [rules, .continuerules, system, prompt, message]
|
||||
---
|
||||
|
||||
# `.continuerules`
|
||||
|
||||
You can create a project-specific system message by adding a `.continuerules` file to the root of your project. This file is raw text and its contents will be inserted into the system message for all LLM requests.
|
||||
|
||||
## Simple Examples
|
||||
|
||||
- If you want concise answers:
|
||||
|
||||
```title=.continuerules
|
||||
Please provide concise answers. Do explain obvious concepts. You can assume that I am knowledgable about most programming topics.
|
||||
```
|
||||
|
||||
- If you want to ensure certain practices are followed, for example in React:
|
||||
|
||||
```title=.continuerules
|
||||
Whenever you are writing React code, make sure to
|
||||
- use functional components instead of class components
|
||||
- use hooks for state management
|
||||
- define an interface for your component props
|
||||
- use Tailwind CSS for styling
|
||||
- modularize components into smaller, reusable pieces
|
||||
```
|
||||
6
docs/package-lock.json
generated
6
docs/package-lock.json
generated
|
|
@ -5229,9 +5229,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||
"version": "7.0.5",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz",
|
||||
"integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==",
|
||||
"dependencies": {
|
||||
"path-key": "^3.1.0",
|
||||
"shebang-command": "^2.0.0",
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ repositories { mavenCentral() }
|
|||
// https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
|
||||
dependencies {
|
||||
// implementation(libs.annotations)
|
||||
implementation("com.squareup.okhttp3:okhttp:4.9.2") {
|
||||
implementation("com.squareup.okhttp3:okhttp:4.12.0") {
|
||||
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
|
||||
}
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.32")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension
|
|||
pluginName=continue-intellij-extension
|
||||
pluginRepositoryUrl=https://github.com/continuedev/continue
|
||||
# SemVer format -> https://semver.org
|
||||
pluginVersion=0.0.81
|
||||
pluginVersion=0.0.82
|
||||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
|
||||
pluginSinceBuild=223
|
||||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.github.continuedev.continueintellijextension.activities
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.project.Project
|
||||
|
||||
/**
|
||||
* The service is a parent disposable that represents the entire plugin lifecycle
|
||||
* and is intended to be used instead of the project/application as a parent disposable,
|
||||
* ensures that disposables registered using it as parents will be processed when the plugin is unloaded to avoid memory leaks.
|
||||
*
|
||||
* @author lk
|
||||
*/
|
||||
@Service(Service.Level.APP, Service.Level.PROJECT)
|
||||
class ContinuePluginDisposable : Disposable {
|
||||
|
||||
override fun dispose() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun getInstance(): ContinuePluginDisposable {
|
||||
return ApplicationManager.getApplication().getService(ContinuePluginDisposable::class.java)
|
||||
}
|
||||
|
||||
fun getInstance(project: Project): ContinuePluginDisposable {
|
||||
return project.getService(ContinuePluginDisposable::class.java)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -70,8 +70,7 @@ private fun getTutorialFileName(): String {
|
|||
}
|
||||
}
|
||||
|
||||
class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware {
|
||||
private val coroutineScope = CoroutineScope(Dispatchers.IO)
|
||||
class ContinuePluginStartupActivity : StartupActivity, DumbAware {
|
||||
|
||||
override fun runActivity(project: Project) {
|
||||
removeShortcutFromAction(getPlatformSpecificKeyStroke("J"))
|
||||
|
|
@ -110,6 +109,7 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware {
|
|||
}
|
||||
|
||||
private fun initializePlugin(project: Project) {
|
||||
val coroutineScope = CoroutineScope(Dispatchers.IO)
|
||||
val continuePluginService = ServiceManager.getService(
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
|
|
@ -169,8 +169,8 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware {
|
|||
|
||||
// Create a data map if there are any paths to re-index
|
||||
if (allPaths.isNotEmpty()) {
|
||||
val data = mapOf("dirs" to allPaths)
|
||||
continuePluginService.coreMessenger?.request("index/forceReIndex", data, null) { _ -> }
|
||||
val data = mapOf("files" to allPaths)
|
||||
continuePluginService.coreMessenger?.request("index/forceReIndexFiles", data, null) { _ -> }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -225,16 +225,11 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware {
|
|||
|
||||
EditorFactory.getInstance().eventMulticaster.addSelectionListener(
|
||||
listener,
|
||||
this@ContinuePluginStartupActivity
|
||||
ContinuePluginDisposable.getInstance(project)
|
||||
)
|
||||
|
||||
val coreMessengerManager = CoreMessengerManager(project, ideProtocolClient, coroutineScope)
|
||||
continuePluginService.coreMessengerManager = coreMessengerManager
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
// Cleanup resources here
|
||||
coroutineScope.cancel()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.continuedev.continueintellijextension.autocomplete
|
||||
|
||||
import com.github.continuedev.continueintellijextension.activities.ContinuePluginDisposable
|
||||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.components.service
|
||||
|
|
@ -35,7 +36,7 @@ class AutocompleteSpinnerWidget(project: Project) : EditorBasedWidget(project),
|
|||
)
|
||||
|
||||
init {
|
||||
Disposer.register(project, this)
|
||||
Disposer.register(ContinuePluginDisposable.getInstance(project), this)
|
||||
updateIcon()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class CoreMessenger(
|
|||
private val project: Project,
|
||||
continueCorePath: String,
|
||||
private val ideProtocolClient: IdeProtocolClient,
|
||||
coroutineScope: CoroutineScope
|
||||
val coroutineScope: CoroutineScope
|
||||
) {
|
||||
private var writer: Writer? = null
|
||||
private var reader: BufferedReader? = null
|
||||
|
|
@ -232,4 +232,11 @@ class CoreMessenger(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun killSubProcess() {
|
||||
process?.isAlive?.let {
|
||||
exitCallbacks.clear()
|
||||
process?.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.continuedev.continueintellijextension.`continue`
|
||||
|
||||
import com.github.continuedev.continueintellijextension.activities.ContinuePluginDisposable
|
||||
import com.github.continuedev.continueintellijextension.auth.AuthListener
|
||||
import com.github.continuedev.continueintellijextension.auth.ContinueAuthService
|
||||
import com.github.continuedev.continueintellijextension.constants.getConfigJsPath
|
||||
|
|
@ -105,7 +106,7 @@ class AsyncFileSaveListener(private val ideProtocolClient: IdeProtocolClient) :
|
|||
for (event in events) {
|
||||
if (event.path.endsWith(".continue/config.json") || event.path.endsWith(".continue/config.ts") || event.path.endsWith(
|
||||
".continue\\config.json"
|
||||
) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json")
|
||||
) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") || event.path.endsWith(".continuerc.json")
|
||||
) {
|
||||
return object : AsyncFileListener.ChangeApplier {
|
||||
override fun afterVfsChange() {
|
||||
|
|
@ -132,9 +133,9 @@ class IdeProtocolClient(
|
|||
initIdeProtocol()
|
||||
|
||||
// Setup config.json / config.ts save listeners
|
||||
VirtualFileManager.getInstance().addAsyncFileListener(AsyncFileSaveListener(this), object : Disposable {
|
||||
override fun dispose() {}
|
||||
})
|
||||
VirtualFileManager.getInstance().addAsyncFileListener(
|
||||
AsyncFileSaveListener(this), ContinuePluginDisposable.getInstance(project)
|
||||
)
|
||||
|
||||
val myPluginId = "com.github.continuedev.continueintellijextension"
|
||||
val pluginDescriptor =
|
||||
|
|
|
|||
|
|
@ -109,14 +109,14 @@ class DiffStreamHandler(
|
|||
}
|
||||
|
||||
updateProgressHighlighters(type)
|
||||
|
||||
// Since we only call onLastDiffLine() when we reach a "same" line, we need to handle the case where
|
||||
// we reach EOF while in a diff block, since we won't encounter a "same" line.
|
||||
if (curLine.index >= editor.document.lineCount - 1) {
|
||||
curLine.diffBlock?.onLastDiffLine()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("Error handling diff line: ${curLine.index}, $type, $text, ${e.message}")
|
||||
println(
|
||||
"Error handling diff line - " +
|
||||
"Line index: ${curLine.index}, " +
|
||||
"Line type: $type, " +
|
||||
"Line text: $text, " +
|
||||
"Error message: ${e.message}"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ class DiffStreamHandler(
|
|||
val diffBlock = VerticalDiffBlock(
|
||||
editor, project, curLine.index, ::handleDiffBlockAcceptOrReject
|
||||
)
|
||||
|
||||
|
||||
diffBlocks.add(diffBlock)
|
||||
|
||||
return diffBlock
|
||||
|
|
@ -251,9 +251,12 @@ class DiffStreamHandler(
|
|||
}
|
||||
|
||||
private fun handleFinishedResponse() {
|
||||
onFinish()
|
||||
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
// Since we only call onLastDiffLine() when we reach a "same" line, we need to handle the case where
|
||||
// the last line in the diff stream is in the middle of a diff block.
|
||||
curLine.diffBlock?.onLastDiffLine()
|
||||
|
||||
onFinish()
|
||||
cleanupProgressHighlighters()
|
||||
}
|
||||
}
|
||||
|
|
@ -267,9 +270,12 @@ class DiffStreamHandler(
|
|||
private fun handleDiffLineResponse(parsed: Map<*, *>) {
|
||||
val data = parsed["content"] as Map<*, *>
|
||||
val diffLineType = getDiffLineType(data["type"] as String)
|
||||
val lineText = data["line"] as String
|
||||
|
||||
WriteCommandAction.runWriteCommandAction(project) {
|
||||
handleDiffLine(diffLineType, data["line"] as String)
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
WriteCommandAction.runWriteCommandAction(project) {
|
||||
handleDiffLine(diffLineType, lineText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ import org.jdesktop.swingx.JXTextArea
|
|||
|
||||
const val MAIN_FONT_SIZE = 13
|
||||
|
||||
const val DOWN_ARROW = " ▾"
|
||||
|
||||
fun makeTextArea(): JTextArea {
|
||||
val textArea =
|
||||
CustomTextArea(1, 40).apply {
|
||||
|
|
@ -48,7 +50,7 @@ fun makeTextArea(): JTextArea {
|
|||
isOpaque = false
|
||||
background = GetTheme().getSecondaryDark()
|
||||
maximumSize = Dimension(400, Short.MAX_VALUE.toInt())
|
||||
margin = JBUI.insets(6, 8, 6, 4)
|
||||
margin = JBUI.insets(6, 8, 2, 4)
|
||||
font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE)
|
||||
preferredSize = Dimension(400, 75)
|
||||
}
|
||||
|
|
@ -206,7 +208,7 @@ fun openInlineEdit(project: Project?, editor: Editor) {
|
|||
val comboBoxRef = Ref<JComboBox<String>>()
|
||||
|
||||
fun onEnter() {
|
||||
val selectedModelStrippedOfCaret = (comboBoxRef.get().selectedItem as String).removeSuffix(" ▾")
|
||||
val selectedModelStrippedOfCaret = (comboBoxRef.get().selectedItem as String).removeSuffix(DOWN_ARROW)
|
||||
customPanelRef.get().enter()
|
||||
diffStreamHandler.streamDiffLinesToEditor(
|
||||
textArea.text, prefix, highlighted, suffix, selectedModelStrippedOfCaret
|
||||
|
|
@ -425,7 +427,7 @@ class CustomPanel(
|
|||
}
|
||||
|
||||
selectedIndex =
|
||||
continueSettingsService.continueState.lastSelectedInlineEditModel?.let {
|
||||
if(itemCount == 0) -1 else continueSettingsService.continueState.lastSelectedInlineEditModel?.let {
|
||||
if (modelTitles.isEmpty()) -1
|
||||
else {
|
||||
val index = modelTitles.indexOf(it)
|
||||
|
|
@ -435,7 +437,7 @@ class CustomPanel(
|
|||
|
||||
addActionListener {
|
||||
continueSettingsService.continueState.lastSelectedInlineEditModel =
|
||||
selectedItem as String
|
||||
(selectedItem as String).removeSuffix(DOWN_ARROW)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -711,7 +713,7 @@ class TransparentArrowButtonUI : BasicComboBoxUI() {
|
|||
|
||||
override fun getSelectedItem(): Any? {
|
||||
val item = originalModel.selectedItem
|
||||
return "$item ▾"
|
||||
return "$item$DOWN_ARROW"
|
||||
}
|
||||
|
||||
override fun addListDataListener(l: ListDataListener?) {
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ class ToolTipComponent(editor: Editor, x: Int, y: Int) :
|
|||
val componentHorizontalPadding = 4
|
||||
val buttonMargin = 4
|
||||
|
||||
addToChatButton = StyledButton("Chat (${cmdCtrlChar}J)")
|
||||
editButton = StyledButton("Edit (${cmdCtrlChar}I)")
|
||||
addToChatButton = StyledButton("Chat (${cmdCtrlChar}+J)")
|
||||
editButton = StyledButton("Edit (${cmdCtrlChar}+I)")
|
||||
|
||||
addToChatButton.addActionListener { e: ActionEvent? ->
|
||||
focusContinueInput(editor.project)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class VerticalDiffBlock(
|
|||
private val rejectButton: JButton
|
||||
private var deletionInlay: Disposable? = null
|
||||
private var textArea: JTextArea? = null // Used for calculation of the text area height when rendering buttons
|
||||
private var hasRenderedDiffBlock: Boolean = false
|
||||
private val editorComponentInlaysManager = EditorComponentInlaysManager.from(editor, false)
|
||||
private val greenKey = createTextAttributesKey("CONTINUE_DIFF_NEW_LINE", 0x3000FF00, editor)
|
||||
|
||||
|
|
@ -81,11 +82,19 @@ class VerticalDiffBlock(
|
|||
}
|
||||
|
||||
fun onLastDiffLine() {
|
||||
// Handles the case where we are invoking one last time on last line of diff stream, but the block has
|
||||
// already been rendered
|
||||
if (hasRenderedDiffBlock) {
|
||||
return
|
||||
}
|
||||
|
||||
if (deletedLines.size > 0) {
|
||||
renderDeletedLinesInlay()
|
||||
}
|
||||
|
||||
renderButtons()
|
||||
|
||||
hasRenderedDiffBlock = true
|
||||
}
|
||||
|
||||
fun handleReject() {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ class ContinuePluginService(project: Project) : Disposable, DumbAware {
|
|||
|
||||
override fun dispose() {
|
||||
coroutineScope.cancel()
|
||||
coreMessenger?.coroutineScope?.let {
|
||||
it.cancel()
|
||||
coreMessenger?.killSubProcess()
|
||||
}
|
||||
}
|
||||
|
||||
fun sendToWebview(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.continuedev.continueintellijextension.toolWindow
|
||||
|
||||
import com.github.continuedev.continueintellijextension.activities.ContinuePluginDisposable
|
||||
import com.github.continuedev.continueintellijextension.activities.showTutorial
|
||||
import com.github.continuedev.continueintellijextension.constants.MessageTypes
|
||||
import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath
|
||||
|
|
@ -18,8 +19,6 @@ import kotlinx.coroutines.*
|
|||
import org.cef.CefApp
|
||||
import org.cef.browser.CefBrowser
|
||||
import org.cef.handler.CefLoadHandlerAdapter
|
||||
import com.intellij.openapi.application.ApplicationInfo
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
|
||||
class ContinueBrowser(val project: Project, url: String) {
|
||||
private val coroutineScope = CoroutineScope(
|
||||
|
|
@ -60,6 +59,7 @@ class ContinueBrowser(val project: Project, url: String) {
|
|||
"stats/getTokensPerModel",
|
||||
"index/setPaused",
|
||||
"index/forceReIndex",
|
||||
"index/forceReIndexFiles",
|
||||
"index/indexingProgressBarInitialized",
|
||||
"completeOnboarding",
|
||||
"addAutocompleteModel",
|
||||
|
|
@ -79,8 +79,8 @@ class ContinueBrowser(val project: Project, url: String) {
|
|||
val browser: JBCefBrowser
|
||||
|
||||
init {
|
||||
val enableOSR = ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR
|
||||
this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(enableOSR).build()
|
||||
val isOSREnabled = ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR
|
||||
this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(isOSREnabled).build()
|
||||
|
||||
|
||||
browser.jbCefClient.setProperty(
|
||||
|
|
@ -90,7 +90,7 @@ class ContinueBrowser(val project: Project, url: String) {
|
|||
|
||||
registerAppSchemeHandler()
|
||||
browser.loadURL(url);
|
||||
Disposer.register(project, browser)
|
||||
Disposer.register(ContinuePluginDisposable.getInstance(project), browser)
|
||||
|
||||
// Listen for events sent from browser
|
||||
val myJSQueryOpenInBrowser = JBCefJSQuery.create((browser as JBCefBrowserBase?)!!)
|
||||
|
|
@ -136,6 +136,10 @@ class ContinueBrowser(val project: Project, url: String) {
|
|||
heightChangeListeners.forEach { it(height) }
|
||||
}
|
||||
|
||||
"jetbrains/isOSREnabled" -> {
|
||||
sendToWebview( "jetbrains/isOSREnabled", isOSREnabled)
|
||||
}
|
||||
|
||||
"onLoad" -> {
|
||||
coroutineScope.launch {
|
||||
// Set the colors to match Intellij theme
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
|
|||
|
||||
Pre-release Changes
|
||||
### Added
|
||||
* New Edit mode in sidebar (cmd/ctrl+I)
|
||||
* Significantly faster and more accurate docs crawler by default
|
||||
* OpenAI predicted outputs support
|
||||
* Improve codebase retrieval with BM25
|
||||
* Support for Grok from xAI
|
||||
|
|
@ -19,12 +17,19 @@ Pre-release Changes
|
|||
* Improved reference for config.json
|
||||
* New @web context provider
|
||||
* Updates for llama3.2
|
||||
* .continuerules file to set system prompt
|
||||
* .prompt files v2
|
||||
### Changed
|
||||
* Improved @docs crawler
|
||||
* Many improvements to make autocomplete more eager
|
||||
### Fixed
|
||||
* Brought back the Apply button for all code blocks
|
||||
|
||||
## 0.8.56 - 2024-11-08
|
||||
### Added
|
||||
* New Edit mode in sidebar (cmd/ctrl+I)
|
||||
* Significantly faster and more accurate docs crawler by default
|
||||
|
||||
## 0.8.55 - 2024-10-25
|
||||
### Added
|
||||
* Web context provider
|
||||
|
|
|
|||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.228",
|
||||
"version": "0.9.231",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.228",
|
||||
"version": "0.9.231",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "0.9.228",
|
||||
"version": "0.9.231",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
@ -331,12 +331,14 @@
|
|||
{
|
||||
"command": "continue.acceptDiff",
|
||||
"mac": "shift+cmd+enter",
|
||||
"key": "shift+ctrl+enter"
|
||||
"key": "shift+ctrl+enter",
|
||||
"when": "continue.diffVisible"
|
||||
},
|
||||
{
|
||||
"command": "continue.rejectDiff",
|
||||
"mac": "shift+cmd+backspace",
|
||||
"key": "shift+ctrl+backspace"
|
||||
"key": "shift+ctrl+backspace",
|
||||
"when": "continue.diffVisible"
|
||||
},
|
||||
{
|
||||
"command": "continue.rejectDiff",
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ export class ContinueCompletionProvider
|
|||
showFreeTrialLoginMessage(
|
||||
e.message,
|
||||
this.configHandler.reloadConfig.bind(this.configHandler),
|
||||
() => this.webviewProtocol.request("openOnboardingCard", undefined),
|
||||
() => {
|
||||
void this.webviewProtocol.request("openOnboardingCard", undefined)
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ const commandsMap: (
|
|||
const modelTitle =
|
||||
getModelByRole(config, "inlineEdit")?.title ?? defaultModelTitle;
|
||||
|
||||
sidebar.webviewProtocol.request("incrementFtc", undefined);
|
||||
void sidebar.webviewProtocol.request("incrementFtc", undefined);
|
||||
|
||||
await verticalDiffManager.streamEdit(
|
||||
config.experimental?.contextMenuPrompts?.[promptName] ?? fallbackPrompt,
|
||||
|
|
@ -287,7 +287,7 @@ const commandsMap: (
|
|||
verticalDiffManager.clearForFilepath(fullPath, true);
|
||||
await diffManager.acceptDiff(fullPath);
|
||||
|
||||
await sidebar.webviewProtocol.request("setEditStatus", {
|
||||
void sidebar.webviewProtocol.request("setEditStatus", {
|
||||
status: "done",
|
||||
});
|
||||
},
|
||||
|
|
@ -306,7 +306,7 @@ const commandsMap: (
|
|||
|
||||
verticalDiffManager.clearForFilepath(fullPath, false);
|
||||
await diffManager.rejectDiff(fullPath);
|
||||
await sidebar.webviewProtocol.request("setEditStatus", {
|
||||
void sidebar.webviewProtocol.request("setEditStatus", {
|
||||
status: "done",
|
||||
});
|
||||
},
|
||||
|
|
@ -387,12 +387,12 @@ const commandsMap: (
|
|||
if (historyLength === 0) {
|
||||
hideGUI();
|
||||
} else {
|
||||
sidebar.webviewProtocol?.request("focusContinueInput", undefined);
|
||||
void sidebar.webviewProtocol?.request("focusContinueInput", undefined);
|
||||
}
|
||||
} else {
|
||||
focusGUI();
|
||||
sidebar.webviewProtocol?.request("focusContinueInput", undefined);
|
||||
await addHighlightedCodeToContext(sidebar.webviewProtocol);
|
||||
void addHighlightedCodeToContext(sidebar.webviewProtocol);
|
||||
}
|
||||
},
|
||||
"continue.focusContinueInputWithoutClear": async () => {
|
||||
|
|
@ -419,7 +419,7 @@ const commandsMap: (
|
|||
undefined,
|
||||
);
|
||||
|
||||
await addHighlightedCodeToContext(sidebar.webviewProtocol);
|
||||
void addHighlightedCodeToContext(sidebar.webviewProtocol);
|
||||
}
|
||||
},
|
||||
"continue.edit": async () => {
|
||||
|
|
@ -596,10 +596,10 @@ const commandsMap: (
|
|||
prompt: "Enter the Session ID",
|
||||
});
|
||||
}
|
||||
sidebar.webviewProtocol?.request("focusContinueSessionId", { sessionId });
|
||||
void sidebar.webviewProtocol?.request("focusContinueSessionId", { sessionId });
|
||||
},
|
||||
"continue.applyCodeFromChat": () => {
|
||||
sidebar.webviewProtocol.request("applyCodeFromChat", undefined);
|
||||
void sidebar.webviewProtocol.request("applyCodeFromChat", undefined);
|
||||
},
|
||||
"continue.toggleFullScreen": () => {
|
||||
focusGUI();
|
||||
|
|
|
|||
|
|
@ -25,9 +25,12 @@ export class VerticalDiffHandler implements vscode.Disposable {
|
|||
private currentLineIndex: number;
|
||||
private cancelled = false;
|
||||
private newLinesAdded = 0;
|
||||
private get diffBlocks() {
|
||||
return this.editorToVerticalDiffCodeLens.get(this.filepath) || [];
|
||||
private deletionBuffer: string[] = [];
|
||||
private redDecorationManager: DecorationTypeRangeManager;
|
||||
private get filepath() {
|
||||
return this.editor.document.uri.fsPath;
|
||||
}
|
||||
public insertedInCurrentBlock = 0;
|
||||
public get range(): vscode.Range {
|
||||
const startLine = Math.min(this.startLine, this.endLine);
|
||||
const endLine = Math.max(this.startLine, this.endLine);
|
||||
|
|
@ -77,14 +80,6 @@ export class VerticalDiffHandler implements vscode.Disposable {
|
|||
this.disposables.push(disposable);
|
||||
}
|
||||
|
||||
private get filepath() {
|
||||
return this.editor.document.uri.fsPath;
|
||||
}
|
||||
|
||||
private deletionBuffer: string[] = [];
|
||||
private redDecorationManager: DecorationTypeRangeManager;
|
||||
insertedInCurrentBlock = 0;
|
||||
|
||||
private async insertDeletionBuffer() {
|
||||
// Don't remove trailing whitespace line
|
||||
const totalDeletedContent = this.deletionBuffer.join("\n");
|
||||
|
|
@ -98,13 +93,15 @@ export class VerticalDiffHandler implements vscode.Disposable {
|
|||
}
|
||||
|
||||
if (this.deletionBuffer.length || this.insertedInCurrentBlock > 0) {
|
||||
this.diffBlocks.push({
|
||||
const blocks = this.editorToVerticalDiffCodeLens.get(this.filepath) || [];
|
||||
|
||||
blocks.push({
|
||||
start: this.currentLineIndex - this.insertedInCurrentBlock,
|
||||
numRed: this.deletionBuffer.length,
|
||||
numGreen: this.insertedInCurrentBlock,
|
||||
});
|
||||
|
||||
this.editorToVerticalDiffCodeLens.set(this.filepath, this.diffBlocks);
|
||||
this.editorToVerticalDiffCodeLens.set(this.filepath, blocks);
|
||||
}
|
||||
|
||||
if (this.deletionBuffer.length === 0) {
|
||||
|
|
@ -271,7 +268,10 @@ export class VerticalDiffHandler implements vscode.Disposable {
|
|||
},
|
||||
);
|
||||
|
||||
this.options.onStatusUpdate("closed", this.diffBlocks.length);
|
||||
this.options.onStatusUpdate(
|
||||
"closed",
|
||||
this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0,
|
||||
);
|
||||
|
||||
this.cancelled = true;
|
||||
this.refreshCodeLens();
|
||||
|
|
@ -359,7 +359,10 @@ export class VerticalDiffHandler implements vscode.Disposable {
|
|||
|
||||
this.refreshCodeLens();
|
||||
|
||||
this.options.onStatusUpdate("done", this.diffBlocks.length);
|
||||
this.options.onStatusUpdate(
|
||||
"done",
|
||||
this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0,
|
||||
);
|
||||
|
||||
// Reject on user typing
|
||||
// const listener = vscode.workspace.onDidChangeTextDocument((e) => {
|
||||
|
|
@ -409,8 +412,11 @@ export class VerticalDiffHandler implements vscode.Disposable {
|
|||
// Shift the codelens objects
|
||||
this.shiftCodeLensObjects(startLine, offset);
|
||||
|
||||
const status = this.diffBlocks.length === 0 ? "closed" : undefined;
|
||||
this.options.onStatusUpdate(status, this.diffBlocks.length);
|
||||
const numDiffs =
|
||||
this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0;
|
||||
|
||||
const status = numDiffs === 0 ? "closed" : undefined;
|
||||
this.options.onStatusUpdate(status, numDiffs);
|
||||
}
|
||||
|
||||
private shiftCodeLensObjects(startLine: number, offset: number) {
|
||||
|
|
@ -450,6 +456,7 @@ export class VerticalDiffHandler implements vscode.Disposable {
|
|||
}
|
||||
|
||||
public hasDiffForCurrentFile(): boolean {
|
||||
return this.diffBlocks.length > 0;
|
||||
const diffBlocks = this.editorToVerticalDiffCodeLens.get(this.filepath);
|
||||
return diffBlocks !== undefined && diffBlocks.length > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ export class VerticalDiffManager {
|
|||
{
|
||||
instant,
|
||||
onStatusUpdate: (status, numDiffs) =>
|
||||
this.webviewProtocol.request("updateApplyState", {
|
||||
void this.webviewProtocol.request("updateApplyState", {
|
||||
streamId,
|
||||
status,
|
||||
numDiffs,
|
||||
|
|
@ -338,7 +338,7 @@ export class VerticalDiffManager {
|
|||
input,
|
||||
onStatusUpdate: (status, numDiffs) =>
|
||||
streamId &&
|
||||
this.webviewProtocol.request("updateApplyState", {
|
||||
void this.webviewProtocol.request("updateApplyState", {
|
||||
streamId,
|
||||
status,
|
||||
numDiffs,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import { VsCodeIde } from "../VsCodeIde";
|
|||
|
||||
import { VsCodeMessenger } from "./VsCodeMessenger";
|
||||
|
||||
import { SYSTEM_PROMPT_DOT_FILE } from "core/config/getSystemPromptDotFile";
|
||||
import type { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
||||
export class VsCodeExtension {
|
||||
|
|
@ -284,7 +285,8 @@ export class VsCodeExtension {
|
|||
|
||||
if (
|
||||
filepath.endsWith(".continuerc.json") ||
|
||||
filepath.endsWith(".prompt")
|
||||
filepath.endsWith(".prompt") ||
|
||||
filepath.endsWith(SYSTEM_PROMPT_DOT_FILE)
|
||||
) {
|
||||
this.configHandler.reloadConfig();
|
||||
} else if (
|
||||
|
|
@ -295,15 +297,21 @@ export class VsCodeExtension {
|
|||
this.core.invoke("index/forceReIndex", undefined);
|
||||
} else {
|
||||
// Reindex the file
|
||||
this.core.invoke("index/forceReIndex", {
|
||||
dirs: [filepath]
|
||||
this.core.invoke("index/forceReIndexFiles", {
|
||||
files: [filepath],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
vscode.workspace.onDidDeleteFiles(async (event) => {
|
||||
this.core.invoke("index/forceReIndex", {
|
||||
dirs: event.files.map((file) => file.fsPath.split("/").slice(0, -1).join("/"))
|
||||
this.core.invoke("index/forceReIndexFiles", {
|
||||
files: event.files.map((file) => file.fsPath),
|
||||
});
|
||||
});
|
||||
|
||||
vscode.workspace.onDidCreateFiles(async (event) => {
|
||||
this.core.invoke("index/forceReIndexFiles", {
|
||||
files: event.files.map((file) => file.fsPath),
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -314,14 +322,14 @@ export class VsCodeExtension {
|
|||
} else if (e.provider.id === controlPlaneEnv.AUTH_TYPE) {
|
||||
const sessionInfo = await getControlPlaneSessionInfo(true);
|
||||
this.webviewProtocolPromise.then(async (webviewProtocol) => {
|
||||
webviewProtocol.request("didChangeControlPlaneSessionInfo", {
|
||||
void webviewProtocol.request("didChangeControlPlaneSessionInfo", {
|
||||
sessionInfo,
|
||||
});
|
||||
|
||||
// To make sure continue-proxy models and anything else requiring it get updated access token
|
||||
this.configHandler.reloadConfig();
|
||||
});
|
||||
this.core.invoke("didChangeControlPlaneSessionInfo", { sessionInfo });
|
||||
void this.core.invoke("didChangeControlPlaneSessionInfo", { sessionInfo });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -352,7 +360,8 @@ export class VsCodeExtension {
|
|||
|
||||
// Register a content provider for the readonly virtual documents
|
||||
const documentContentProvider = new (class
|
||||
implements vscode.TextDocumentContentProvider {
|
||||
implements vscode.TextDocumentContentProvider
|
||||
{
|
||||
// emitter and its event
|
||||
onDidChangeEmitter = new vscode.EventEmitter<vscode.Uri>();
|
||||
onDidChange = this.onDidChangeEmitter.event;
|
||||
|
|
@ -369,14 +378,14 @@ export class VsCodeExtension {
|
|||
);
|
||||
|
||||
this.ide.onDidChangeActiveTextEditor((filepath) => {
|
||||
this.core.invoke("didChangeActiveTextEditor", { filepath });
|
||||
void this.core.invoke("didChangeActiveTextEditor", { filepath });
|
||||
});
|
||||
|
||||
vscode.workspace.onDidChangeConfiguration(async (event) => {
|
||||
if (event.affectsConfiguration(EXTENSION_NAME)) {
|
||||
const settings = this.ide.getIdeSettingsSync();
|
||||
const webviewProtocol = await this.webviewProtocolPromise;
|
||||
webviewProtocol.request("didChangeIdeSettings", {
|
||||
void webviewProtocol.request("didChangeIdeSettings", {
|
||||
settings,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export class VsCodeMessenger {
|
|||
message: Message<FromWebviewProtocol[T][0]>,
|
||||
) => Promise<FromWebviewProtocol[T][1]> | FromWebviewProtocol[T][1],
|
||||
): void {
|
||||
this.webviewProtocol.on(messageType, handler);
|
||||
void this.webviewProtocol.on(messageType, handler);
|
||||
}
|
||||
|
||||
onCore<T extends keyof ToIdeOrWebviewFromCoreProtocol>(
|
||||
|
|
@ -153,11 +153,11 @@ export class VsCodeMessenger {
|
|||
});
|
||||
|
||||
webviewProtocol.on("acceptDiff", async ({ data: { filepath } }) => {
|
||||
await vscode.commands.executeCommand("continue.acceptDiff", filepath);
|
||||
void vscode.commands.executeCommand("continue.acceptDiff", filepath);
|
||||
});
|
||||
|
||||
webviewProtocol.on("rejectDiff", async ({ data: { filepath } }) => {
|
||||
await vscode.commands.executeCommand("continue.rejectDiff", filepath);
|
||||
void vscode.commands.executeCommand("continue.rejectDiff", filepath);
|
||||
});
|
||||
|
||||
this.onWebview("applyToFile", async ({ data }) => {
|
||||
|
|
@ -178,7 +178,7 @@ export class VsCodeMessenger {
|
|||
await this.ide.writeFile(fullPath, data.text);
|
||||
await this.ide.openFile(fullPath);
|
||||
|
||||
await webviewProtocol.request("updateApplyState", {
|
||||
void webviewProtocol.request("updateApplyState", {
|
||||
streamId: data.streamId,
|
||||
status: "done",
|
||||
numDiffs: 0,
|
||||
|
|
@ -203,7 +203,7 @@ export class VsCodeMessenger {
|
|||
editor.edit((builder) =>
|
||||
builder.insert(new vscode.Position(0, 0), data.text),
|
||||
);
|
||||
await webviewProtocol.request("updateApplyState", {
|
||||
void webviewProtocol.request("updateApplyState", {
|
||||
streamId: data.streamId,
|
||||
status: "done",
|
||||
numDiffs: 0,
|
||||
|
|
@ -328,7 +328,7 @@ export class VsCodeMessenger {
|
|||
),
|
||||
);
|
||||
|
||||
this.webviewProtocol.request("setEditStatus", {
|
||||
void this.webviewProtocol.request("setEditStatus", {
|
||||
status: "accepting",
|
||||
fileAfterEdit,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ export class QuickEdit {
|
|||
prompt = this.contextProviderStr + prompt;
|
||||
}
|
||||
|
||||
this.webviewProtocol.request("incrementFtc", undefined);
|
||||
void this.webviewProtocol.request("incrementFtc", undefined);
|
||||
|
||||
await this.verticalDiffManager.streamEdit(
|
||||
prompt,
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
(
|
||||
(class_declaration
|
||||
(class_heritage
|
||||
(extends_clause
|
||||
(identifier) @base-class
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(
|
||||
(class_declaration
|
||||
(class_heritage
|
||||
(implements_clause
|
||||
(type_identifier) @interface
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
(
|
||||
(class_definition
|
||||
superclasses: (argument_list
|
||||
(identifier) @superclass))
|
||||
)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
(
|
||||
(function_declaration
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation) @param_type
|
||||
)
|
||||
)
|
||||
(type_annotation) @return_type
|
||||
)
|
||||
)
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
(
|
||||
(function_definition
|
||||
(parameters
|
||||
(_
|
||||
(type) @a
|
||||
(#not-match? @a "^(str|int|float|bool|list|dict|tuple)$")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(
|
||||
(function_definition
|
||||
(type) @b
|
||||
(#not-match? @b "^(str|int|float|bool|list|dict|tuple)$")
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
(
|
||||
(function_declaration
|
||||
(parameter_list
|
||||
(parameter_declaration
|
||||
type: (_) @param_type
|
||||
)*
|
||||
)
|
||||
; Optional return type node before the block
|
||||
([_] @return_type)?
|
||||
(block)
|
||||
)
|
||||
)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
(
|
||||
(method_definition
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation) @param_type
|
||||
)
|
||||
)
|
||||
(type_annotation) @return_type
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
(
|
||||
(class_declaration
|
||||
(base_clause
|
||||
(name) @superclass)
|
||||
)
|
||||
)
|
||||
|
||||
(
|
||||
(class_declaration
|
||||
(class_interface_clause
|
||||
(name) @interface)
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
(
|
||||
(function_definition
|
||||
parameters: (formal_parameters
|
||||
(simple_parameter
|
||||
type: (named_type) @param_type
|
||||
)*
|
||||
)
|
||||
return_type: (named_type) @return_type
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
(
|
||||
(method_declaration
|
||||
(formal_parameters
|
||||
(simple_parameter
|
||||
type: (named_type) @param_type
|
||||
)*
|
||||
)
|
||||
return_type: (named_type) @return_type
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
; Match superclass identifiers in a simple inheritance
|
||||
(class_definition
|
||||
superclasses: (argument_list
|
||||
(identifier) @catch)
|
||||
(#not-match? @catch "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$")
|
||||
)
|
||||
|
||||
; Match the value of a keyword argument in class inheritance
|
||||
(class_definition
|
||||
superclasses: (argument_list
|
||||
(keyword_argument
|
||||
(_)
|
||||
(identifier) @catch))
|
||||
(#not-match? @catch "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$")
|
||||
)
|
||||
|
||||
; Match identifiers within subscripts in class inheritance
|
||||
(class_definition
|
||||
superclasses: (argument_list
|
||||
(subscript
|
||||
(identifier) @catch
|
||||
))
|
||||
(#not-match? @catch "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$")
|
||||
)
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
; When the type is a simple identifier:
|
||||
(function_definition
|
||||
parameters: (parameters
|
||||
(typed_parameter
|
||||
type: (type
|
||||
(identifier) @type_identifier)))
|
||||
|
||||
(#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$")
|
||||
)
|
||||
|
||||
; When the type is a generic type with one identifier
|
||||
(function_definition
|
||||
parameters: (parameters
|
||||
(typed_parameter
|
||||
type: (type
|
||||
(generic_type
|
||||
(identifier) @type_identifier))))
|
||||
|
||||
(#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$")
|
||||
)
|
||||
|
||||
; When the generic type has type parameters with one identifier
|
||||
(function_definition
|
||||
parameters: (parameters
|
||||
(typed_parameter
|
||||
type: (type
|
||||
(generic_type
|
||||
(identifier)
|
||||
(type_parameter
|
||||
(type
|
||||
(identifier) @type_identifier))))))
|
||||
|
||||
(#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$")
|
||||
)
|
||||
|
||||
; When the return type is a simple identifier
|
||||
(function_definition
|
||||
return_type: (type
|
||||
(identifier) @type_identifier)
|
||||
(#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$")
|
||||
)
|
||||
|
||||
; When the return type is a generic type with one identifier
|
||||
(function_definition
|
||||
return_type: (type
|
||||
(generic_type
|
||||
(identifier) @type_identifier))
|
||||
(#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$")
|
||||
)
|
||||
|
||||
; When the generic type has type parameters with one identifier
|
||||
(function_definition
|
||||
return_type: (type
|
||||
(generic_type
|
||||
(identifier)
|
||||
(type_parameter
|
||||
(type
|
||||
(identifier) @type_identifier))))
|
||||
(#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$")
|
||||
)
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
; Pattern for return type with direct type_identifier
|
||||
(
|
||||
(arrow_function
|
||||
(type_annotation
|
||||
(type_identifier) @return_type
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for return type with one level of nesting
|
||||
(
|
||||
(arrow_function
|
||||
(type_annotation
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for return type with two levels of nesting
|
||||
(
|
||||
(arrow_function
|
||||
(type_annotation
|
||||
(_
|
||||
(_
|
||||
(type_identifier) @return_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with direct type_identifier
|
||||
(
|
||||
(arrow_function
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with one level of nesting
|
||||
(
|
||||
(arrow_function
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with two levels of nesting
|
||||
(
|
||||
(arrow_function
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(_
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
; Match a class declaration that extends a base class
|
||||
; Returns:
|
||||
; @base-class: The identifier of the base class being extended
|
||||
; @generic_argument: The type identifier of the generic argument, if present
|
||||
(class_declaration
|
||||
(class_heritage
|
||||
(extends_clause
|
||||
(identifier) @base-class
|
||||
(type_arguments
|
||||
(type_identifier) @generic_argument
|
||||
)?
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Match a class declaration that implements an interface
|
||||
; Returns:
|
||||
; @interface: The type identifier of the interface being implemented
|
||||
(
|
||||
(class_declaration
|
||||
(class_heritage
|
||||
(implements_clause
|
||||
(type_identifier) @interface
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Match a class declaration that implements a generic interface
|
||||
; Returns:
|
||||
; @interface: The type identifier of the generic interface being implemented
|
||||
; @generic_argument: The type identifier of the generic argument
|
||||
(
|
||||
class_declaration
|
||||
(class_heritage
|
||||
(implements_clause
|
||||
(generic_type
|
||||
(type_identifier) @interface
|
||||
(type_arguments
|
||||
(type_identifier) @generic_argument
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
; Pattern for return type with direct type_identifier
|
||||
(
|
||||
(function_declaration
|
||||
(type_annotation
|
||||
(type_identifier) @return_type
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for return type with one level of nesting
|
||||
(
|
||||
(function_declaration
|
||||
(type_annotation
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for return type with two levels of nesting
|
||||
(
|
||||
(function_declaration
|
||||
(type_annotation
|
||||
(_
|
||||
(_
|
||||
(type_identifier) @return_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with direct type_identifier
|
||||
(
|
||||
(function_declaration
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with one level of nesting
|
||||
(
|
||||
(function_declaration
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with two levels of nesting
|
||||
(
|
||||
(function_declaration
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(_
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
; Pattern for return type with direct type_identifier
|
||||
(
|
||||
(generator_function_declaration
|
||||
(type_annotation
|
||||
(type_identifier) @return_type
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for return type with one level of nesting
|
||||
(
|
||||
(generator_function_declaration
|
||||
(type_annotation
|
||||
(_
|
||||
(type_identifier) @return_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for return type with two levels of nesting
|
||||
(
|
||||
(generator_function_declaration
|
||||
(type_annotation
|
||||
(_
|
||||
(_
|
||||
(type_identifier) @return_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with direct type_identifier
|
||||
(
|
||||
(generator_function_declaration
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with one level of nesting
|
||||
(
|
||||
(generator_function_declaration
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with two levels of nesting
|
||||
(
|
||||
(generator_function_declaration
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(_
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
; Pattern for return type with direct type_identifier
|
||||
(
|
||||
(method_definition
|
||||
(type_annotation
|
||||
(type_identifier) @return_type
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for return type with one level of nesting
|
||||
(
|
||||
(method_definition
|
||||
(type_annotation
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for return type with two levels of nesting
|
||||
(
|
||||
(method_definition
|
||||
(type_annotation
|
||||
(_
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with direct type_identifier
|
||||
(
|
||||
(method_definition
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with one level of nesting
|
||||
(
|
||||
(method_definition
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Pattern for parameters with two levels of nesting
|
||||
(
|
||||
(method_definition
|
||||
(formal_parameters
|
||||
(_
|
||||
(type_annotation
|
||||
(_
|
||||
(_
|
||||
(type_identifier) @param_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -46,13 +46,20 @@ export function History() {
|
|||
const fetchSessions = async () => {
|
||||
const sessions = await getHistory();
|
||||
setSessions(sessions);
|
||||
minisearch.addAll(
|
||||
sessions.map((session) => ({
|
||||
title: session.title,
|
||||
sessionId: session.sessionId,
|
||||
id: session.sessionId,
|
||||
})),
|
||||
);
|
||||
|
||||
try {
|
||||
// Consider adding just last session to existing instead of clearing/adding all
|
||||
minisearch.removeAll();
|
||||
minisearch.addAll(
|
||||
sessions.map((session) => ({
|
||||
title: session.title,
|
||||
sessionId: session.sessionId,
|
||||
id: session.sessionId,
|
||||
})),
|
||||
);
|
||||
} catch (e) {
|
||||
console.log("error adding sessions to minisearch", e);
|
||||
}
|
||||
};
|
||||
fetchSessions();
|
||||
}, [lastSessionId]);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function QuickstartSubmitButton() {
|
|||
force: true,
|
||||
});
|
||||
|
||||
if (result.status === "success" && typeof result.content === "string") {
|
||||
if (result.status === "success") {
|
||||
onComplete();
|
||||
} else {
|
||||
ideMessenger.post("showToast", [
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue