create multiple new prompt files at once

This commit is contained in:
Nate 2024-11-08 17:07:22 -08:00
parent 863ddaf896
commit ad1880c760

View file

@ -6,8 +6,28 @@ import { DEFAULT_PROMPTS_FOLDER_V2 } from "./getPromptFiles";
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
# 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 "---"
# 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
# To learn more, see the full .prompt file reference: https://docs.continue.dev/features/prompt-files
temperature: 0.0
name: Example
description: Example prompt file
version: 2
---
@README.md
@ -30,12 +50,20 @@ export async function createNewPromptFileV2(
"No workspace directories found. Make sure you've opened a folder in your IDE.",
);
}
const promptFilePath = path.join(
const baseDir = path.join(
workspaceDirs[0],
promptPath ?? DEFAULT_PROMPTS_FOLDER_V2,
"new-prompt-file.prompt",
);
// Find the first available filename
let counter = 0;
let promptFilePath: string;
do {
const suffix = counter === 0 ? "" : `-${counter}`;
promptFilePath = path.join(baseDir, `new-prompt-file${suffix}.prompt`);
counter++;
} while (await ide.fileExists(promptFilePath));
const PROMPT_FILE =
new GlobalContext().get("hasAlreadyCreatedAPromptFile") === true
? DEFAULT_PROMPT_FILE