✨ allow non git tracked .prompts folder
This commit is contained in:
parent
ec2a0e55e3
commit
d2a0df92c4
10 changed files with 45 additions and 13 deletions
|
|
@ -9,7 +9,7 @@ export async function getPromptFiles(
|
|||
dir: string,
|
||||
): Promise<{ path: string; content: string }[]> {
|
||||
try {
|
||||
const paths = await ide.listWorkspaceContents(dir);
|
||||
const paths = await ide.listWorkspaceContents(dir, false);
|
||||
const results = paths.map(async (path) => {
|
||||
const content = await ide.readFile(path);
|
||||
return { path, content };
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ declare global {
|
|||
stackDepth: number,
|
||||
): Promise<string[]>;
|
||||
getAvailableThreads(): Promise<Thread[]>;
|
||||
listWorkspaceContents(directory?: string): Promise<string[]>;
|
||||
listWorkspaceContents(directory?: string, useGitIgnore?: boolean): Promise<string[]>;
|
||||
listFolders(): Promise<string[]>;
|
||||
getWorkspaceDirs(): Promise<string[]>;
|
||||
getWorkspaceConfigs(): Promise<ContinueRcJson[]>;
|
||||
|
|
|
|||
5
core/index.d.ts
vendored
5
core/index.d.ts
vendored
|
|
@ -404,7 +404,10 @@ export interface IDE {
|
|||
stackDepth: number,
|
||||
): Promise<string[]>;
|
||||
getAvailableThreads(): Promise<Thread[]>;
|
||||
listWorkspaceContents(directory?: string): Promise<string[]>;
|
||||
listWorkspaceContents(
|
||||
directory?: string,
|
||||
useGitIgnore?: boolean,
|
||||
): Promise<string[]>;
|
||||
listFolders(): Promise<string[]>;
|
||||
getWorkspaceDirs(): Promise<string[]>;
|
||||
getWorkspaceConfigs(): Promise<ContinueRcJson[]>;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@ import { IdeSettings } from "./ideWebview";
|
|||
export type ToIdeFromWebviewOrCoreProtocol = {
|
||||
// Methods from IDE type
|
||||
getIdeInfo: [undefined, IdeInfo];
|
||||
listWorkspaceContents: [undefined, string[]];
|
||||
listWorkspaceContents: [
|
||||
{ directory?: string; useGitIgnore?: boolean },
|
||||
string[],
|
||||
];
|
||||
getWorkspaceDirs: [undefined, string[]];
|
||||
listFolders: [undefined, string[]];
|
||||
writeFile: [{ path: string; contents: string }, void];
|
||||
|
|
|
|||
|
|
@ -110,7 +110,10 @@ class FileSystemIde implements IDE {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
listWorkspaceContents(): Promise<string[]> {
|
||||
listWorkspaceContents(
|
||||
directory?: string,
|
||||
useGitIgnore?: boolean,
|
||||
): Promise<string[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readdir("/tmp/continue", (err, files) => {
|
||||
if (err) {
|
||||
|
|
|
|||
|
|
@ -92,8 +92,14 @@ export class MessageIde implements IDE {
|
|||
return await this.request("getTerminalContents", undefined);
|
||||
}
|
||||
|
||||
async listWorkspaceContents(directory?: string): Promise<string[]> {
|
||||
return await this.request("listWorkspaceContents", undefined);
|
||||
async listWorkspaceContents(
|
||||
directory?: string,
|
||||
useGitIgnore?: boolean,
|
||||
): Promise<string[]> {
|
||||
return await this.request("listWorkspaceContents", {
|
||||
directory,
|
||||
useGitIgnore,
|
||||
});
|
||||
}
|
||||
|
||||
async getWorkspaceDirs(): Promise<string[]> {
|
||||
|
|
|
|||
|
|
@ -219,7 +219,10 @@ export class VsCodeMessenger {
|
|||
);
|
||||
});
|
||||
this.onWebviewOrCore("listWorkspaceContents", async (msg) => {
|
||||
return ide.listWorkspaceContents();
|
||||
return ide.listWorkspaceContents(
|
||||
msg.data.directory,
|
||||
msg.data.useGitIgnore,
|
||||
);
|
||||
});
|
||||
this.onWebviewOrCore("getWorkspaceDirs", async (msg) => {
|
||||
return ide.getWorkspaceDirs();
|
||||
|
|
|
|||
|
|
@ -197,14 +197,23 @@ class VsCodeIde implements IDE {
|
|||
return await this.ideUtils.getAvailableThreads();
|
||||
}
|
||||
|
||||
async listWorkspaceContents(directory?: string): Promise<string[]> {
|
||||
async listWorkspaceContents(
|
||||
directory?: string,
|
||||
useGitIgnore?: boolean,
|
||||
): Promise<string[]> {
|
||||
if (directory) {
|
||||
return await this.ideUtils.getDirectoryContents(directory, true);
|
||||
return await this.ideUtils.getDirectoryContents(
|
||||
directory,
|
||||
true,
|
||||
useGitIgnore ?? true,
|
||||
);
|
||||
}
|
||||
const contents = await Promise.all(
|
||||
this.ideUtils
|
||||
.getWorkspaceDirectories()
|
||||
.map((dir) => this.ideUtils.getDirectoryContents(dir, true)),
|
||||
.map((dir) =>
|
||||
this.ideUtils.getDirectoryContents(dir, true, useGitIgnore ?? true),
|
||||
),
|
||||
);
|
||||
return contents.flat();
|
||||
}
|
||||
|
|
@ -237,6 +246,7 @@ class VsCodeIde implements IDE {
|
|||
[],
|
||||
false,
|
||||
undefined,
|
||||
true,
|
||||
)) {
|
||||
allDirs.push(dir);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,6 +251,7 @@ export class VsCodeIdeUtils {
|
|||
async getDirectoryContents(
|
||||
directory: string,
|
||||
recursive: boolean,
|
||||
useGitIgnore: boolean,
|
||||
): Promise<string[]> {
|
||||
if (!recursive) {
|
||||
return (
|
||||
|
|
@ -276,6 +277,7 @@ export class VsCodeIdeUtils {
|
|||
[],
|
||||
true,
|
||||
gitRoot === directory ? undefined : onlyThisDirectory,
|
||||
useGitIgnore,
|
||||
)) {
|
||||
allFiles.push(file);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ export async function* traverseDirectory(
|
|||
gitIgnorePatterns: string[],
|
||||
returnFiles = true,
|
||||
onlyThisDirectory: string[] | undefined,
|
||||
useGitIgnore: boolean,
|
||||
): AsyncGenerator<string> {
|
||||
const nodes = await vscode.workspace.fs.readDirectory(
|
||||
uriFromFilePath(directory),
|
||||
|
|
@ -79,7 +80,7 @@ export async function* traverseDirectory(
|
|||
|
||||
if (!onlyThisDirectory) {
|
||||
for (const node of returnFiles ? files : dirs) {
|
||||
if (!ig.ignores(node)) {
|
||||
if (!useGitIgnore || !ig.ignores(node)) {
|
||||
yield path.join(directory, node);
|
||||
}
|
||||
}
|
||||
|
|
@ -107,7 +108,7 @@ export async function* traverseDirectory(
|
|||
}
|
||||
|
||||
// Recurse if not ignored
|
||||
if (!(ig.ignores(`${dir}/`) || ig.ignores(dir))) {
|
||||
if (!useGitIgnore || !(ig.ignores(`${dir}/`) || ig.ignores(dir))) {
|
||||
// For patterns who can potentially match items of this subdir, strip the subdir from the start
|
||||
const keepPatterns = [...wildcardPatterns];
|
||||
for (const [startPattern, subDirPatterns] of entries) {
|
||||
|
|
@ -122,6 +123,7 @@ export async function* traverseDirectory(
|
|||
onlyThisDirectory && onlyThisDirectory.length > 1
|
||||
? onlyThisDirectory.slice(1)
|
||||
: undefined,
|
||||
useGitIgnore,
|
||||
)) {
|
||||
yield file;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue