forked from continuedev/continue
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added command retries * barechatfilecontext * Added Reset Session * Added progress * Added working * Added cleanup --------- Co-authored-by: nang-dev <[email protected]> Co-authored-by: Himanshu <[email protected]>
- Loading branch information
1 parent
ba37be1
commit 5886a84
Showing
12 changed files
with
265 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
ContextItem, | ||
ContextProviderDescription, | ||
ContextProviderExtras, | ||
ContextSubmenuItem, | ||
LoadSubmenuItemsArgs, | ||
} from "../../index.js"; | ||
import { walkDir } from "../../indexing/walkDir.js"; | ||
import { | ||
getBasename, | ||
getUniqueFilePath, | ||
groupByLastNPathParts, | ||
} from "../../util/index.js"; | ||
import { BaseContextProvider } from "../index.js"; | ||
|
||
const MAX_SUBMENU_ITEMS = 10_000; | ||
|
||
class RelativeFileContextProvider extends BaseContextProvider { | ||
static description: ContextProviderDescription = { | ||
title: "relativefilecontext", | ||
displayTitle: "Files", | ||
description: "Add file to context.", | ||
type: "submenu", | ||
}; | ||
|
||
async getContextItems( | ||
query: string, | ||
extras: ContextProviderExtras, | ||
): Promise<ContextItem[]> { | ||
const workspaceDirs = await extras.ide.getWorkspaceDirs(); | ||
const relativePath = this.normalizeRelativePath(query, workspaceDirs[0]); | ||
return [ | ||
{ | ||
name: getBasename(query), | ||
description: relativePath, | ||
content: relativePath, | ||
}, | ||
]; | ||
} | ||
|
||
async loadSubmenuItems( | ||
args: LoadSubmenuItemsArgs, | ||
): Promise<ContextSubmenuItem[]> { | ||
const workspaceDirs = await args.ide.getWorkspaceDirs(); | ||
const results = await Promise.all( | ||
workspaceDirs.map((dir) => { | ||
return walkDir(dir, args.ide); | ||
}), | ||
); | ||
const files = results.flat().slice(-MAX_SUBMENU_ITEMS); | ||
const fileGroups = groupByLastNPathParts(files, 2); | ||
|
||
return files.map((file) => { | ||
const relativePath = this.normalizeRelativePath(file, workspaceDirs[0]); | ||
return { | ||
id: file, | ||
title: getBasename(file), | ||
description: relativePath, | ||
}; | ||
}); | ||
} | ||
|
||
private normalizeRelativePath(path: string, workspaceDir: string): string { | ||
const relativePath = path.replace(workspaceDir, "").replace(/^[\/\\]/, ""); | ||
return relativePath.replace(/\\/g, "/"); | ||
} | ||
} | ||
|
||
export default RelativeFileContextProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.