add submenu for repo map context provider
This commit is contained in:
parent
1837de9d90
commit
97b9ebb126
10 changed files with 51 additions and 20 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { INSTRUCTIONS_BASE_ITEM } from ".";
|
||||
import { INSTRUCTIONS_BASE_ITEM } from "./utils";
|
||||
import { BaseContextProvider } from "../";
|
||||
import {
|
||||
Chunk,
|
||||
|
|
|
|||
|
|
@ -3,15 +3,28 @@ import {
|
|||
ContextItem,
|
||||
ContextProviderDescription,
|
||||
ContextProviderExtras,
|
||||
ContextSubmenuItem,
|
||||
LoadSubmenuItemsArgs,
|
||||
} from "../../";
|
||||
import {
|
||||
groupByLastNPathParts,
|
||||
getBasename,
|
||||
getUniqueFilePath,
|
||||
} from "../../util";
|
||||
import generateRepoMap from "../../util/repoMap";
|
||||
|
||||
const ENTIRE_PROJECT_ITEM: ContextSubmenuItem = {
|
||||
id: "entire-workspace",
|
||||
title: "Entire workspace",
|
||||
description: "Search the entire workspace",
|
||||
};
|
||||
|
||||
class RepoMapContextProvider extends BaseContextProvider {
|
||||
static description: ContextProviderDescription = {
|
||||
title: "repo-map",
|
||||
displayTitle: "Repository Map",
|
||||
description: "List of files and signatures",
|
||||
type: "normal",
|
||||
description: "Select a folder",
|
||||
type: "submenu",
|
||||
dependsOnIndexing: true,
|
||||
};
|
||||
|
||||
|
|
@ -23,10 +36,28 @@ class RepoMapContextProvider extends BaseContextProvider {
|
|||
{
|
||||
name: "Repository Map",
|
||||
description: "Overview of the repository structure",
|
||||
content: await generateRepoMap(extras.llm, extras.ide),
|
||||
content: await generateRepoMap(extras.llm, extras.ide, {
|
||||
dirs: query === ENTIRE_PROJECT_ITEM.id ? undefined : [query],
|
||||
}),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
async loadSubmenuItems(
|
||||
args: LoadSubmenuItemsArgs,
|
||||
): Promise<ContextSubmenuItem[]> {
|
||||
const folders = await args.ide.listFolders();
|
||||
const folderGroups = groupByLastNPathParts(folders, 2);
|
||||
|
||||
return [
|
||||
ENTIRE_PROJECT_ITEM,
|
||||
...folders.map((folder) => ({
|
||||
id: folder,
|
||||
title: getBasename(folder),
|
||||
description: getUniqueFilePath(folder, folderGroups),
|
||||
})),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
export default RepoMapContextProvider;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import RepoMapContextProvider from "./RepoMapContextProvider";
|
|||
*
|
||||
* See this issue for details: https://github.com/continuedev/continue/issues/1365
|
||||
*/
|
||||
const Providers: (typeof BaseContextProvider)[] = [
|
||||
export const Providers: (typeof BaseContextProvider)[] = [
|
||||
DiffContextProvider,
|
||||
FileTreeContextProvider,
|
||||
GitHubIssuesContextProvider,
|
||||
|
|
@ -60,9 +60,3 @@ export function contextProviderClassFromName(
|
|||
): typeof BaseContextProvider | undefined {
|
||||
return Providers.find((cls) => cls.description.title === name);
|
||||
}
|
||||
|
||||
export const INSTRUCTIONS_BASE_ITEM: ContextItem = {
|
||||
name: "Instructions",
|
||||
description: "Instructions",
|
||||
content: "",
|
||||
};
|
||||
|
|
|
|||
7
core/context/providers/utils.ts
Normal file
7
core/context/providers/utils.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { ContextItem } from "../..";
|
||||
|
||||
export const INSTRUCTIONS_BASE_ITEM: ContextItem = {
|
||||
name: "Instructions",
|
||||
description: "Instructions",
|
||||
content: "",
|
||||
};
|
||||
|
|
@ -2,7 +2,7 @@ import { BranchAndDir, ContextItem, ContextProviderExtras } from "../../";
|
|||
import TransformersJsEmbeddingsProvider from "../../indexing/embeddings/TransformersJsEmbeddingsProvider";
|
||||
import { resolveRelativePathInWorkspace } from "../../util/ideUtils";
|
||||
import { getRelativePath } from "../../util/";
|
||||
import { INSTRUCTIONS_BASE_ITEM } from "../providers/";
|
||||
import { INSTRUCTIONS_BASE_ITEM } from "../providers/utils";
|
||||
import { RetrievalPipelineOptions } from "./pipelines/BaseRetrievalPipeline";
|
||||
import NoRerankerRetrievalPipeline from "./pipelines/NoRerankerRetrievalPipeline";
|
||||
import RerankerRetrievalPipeline from "./pipelines/RerankerRetrievalPipeline";
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ async function generateRepoMap(llm: ILLM, ide: IDE, options?: RepoMapOptions) {
|
|||
}
|
||||
|
||||
writeStream.end();
|
||||
console.debug(`Generated repo map at ${repoMapPath}`);
|
||||
console.debug(`Generated repo map for ${dirs.join(", ")} at ${repoMapPath}`);
|
||||
|
||||
if (curTokens >= maxRepoMapTokens) {
|
||||
console.debug(
|
||||
|
|
|
|||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.213",
|
||||
"version": "0.9.214",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.213",
|
||||
"version": "0.9.214",
|
||||
"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.213",
|
||||
"version": "0.9.214",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger";
|
|||
import { getFontSize } from "../../util";
|
||||
import FileIcon from "../FileIcon";
|
||||
import SafeImg from "../SafeImg";
|
||||
import { INSTRUCTIONS_BASE_ITEM } from "core/context/providers";
|
||||
import { INSTRUCTIONS_BASE_ITEM } from "core/context/providers/utils";
|
||||
|
||||
const ContextItemDiv = styled.div`
|
||||
cursor: pointer;
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = {
|
|||
docs: BookOpenIcon,
|
||||
issue: ExclamationCircleIcon,
|
||||
trash: TrashIcon,
|
||||
"repo-map": FolderIcon,
|
||||
"/edit": PencilIcon,
|
||||
"/clear": TrashIcon,
|
||||
"/comment": HashtagIcon,
|
||||
|
|
@ -113,9 +114,7 @@ function DropdownIcon(props: { className?: string; item: ComboBoxItem }) {
|
|||
|
||||
const ItemsDiv = styled.div`
|
||||
border-radius: ${defaultBorderRadius};
|
||||
box-shadow:
|
||||
0 0 0 1px rgba(0, 0, 0, 0.05),
|
||||
0px 10px 20px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1);
|
||||
font-size: 0.9rem;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue