Merge pull request #2881 from continuedev/nate/sys-prompt-file
.continuerules
This commit is contained in:
commit
7231f84d99
5 changed files with 44 additions and 5 deletions
1
.instructions
Normal file
1
.instructions
Normal file
|
|
@ -0,0 +1 @@
|
|||
Give concise responses.
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,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() {
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
@ -296,14 +298,16 @@ export class VsCodeExtension {
|
|||
} else {
|
||||
// Reindex the file
|
||||
this.core.invoke("index/forceReIndex", {
|
||||
dirs: [filepath]
|
||||
dirs: [filepath],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
vscode.workspace.onDidDeleteFiles(async (event) => {
|
||||
this.core.invoke("index/forceReIndex", {
|
||||
dirs: event.files.map((file) => file.fsPath.split("/").slice(0, -1).join("/"))
|
||||
dirs: event.files.map((file) =>
|
||||
file.fsPath.split("/").slice(0, -1).join("/"),
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -352,7 +356,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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue