Skip to content

Commit

Permalink
Mount prompt directories even if single-file mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinMcNeil committed Dec 5, 2024
1 parent 5f13c51 commit 8ec969b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/commands/runPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const runPrompt: (secrets: vscode.SecretStorage, mode: PromptOption) => v
await writeToEditor(json.params.messages.map((m: any) => `# ${m.role}\n${m.content}`).join('\n') + '\n');
break;
case 'error':
const errorMSG = String(json.params.content) + String(json.params.message)
const errorMSG = String(json.params.content) + String(json.params.message) + String(json.params.message)

Check warning on line 172 in src/commands/runPrompt.ts

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
await writeToEditor('```error\n' + errorMSG + '\n```\n');
postToBackendSocket({ event: 'eventLabsPromptError', properties: { error: errorMSG } });
break;
Expand Down
10 changes: 7 additions & 3 deletions src/utils/promptRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { setThreadId } from "../commands/setThreadId";
import { notifications } from "./notifications";
import { extensionOutput } from "../extension";
import * as rpc from 'vscode-jsonrpc/node';
import path from "path";

const activePrompts: { [key: string]: Function } = {};

Expand All @@ -20,10 +21,13 @@ export const getRunArgs = async (promptRef: string, projectDir: string, username

if (isLocal) {
const localPromptPath = promptRef.replace('local://', '');
const localPromptDirPath = path.dirname(localPromptPath);
const localPromptDirName = path.basename(localPromptDirPath);
const pathSeparator = platform === 'win32' ? '\\' : '/';
promptRef = localPromptPath.split(pathSeparator).pop() || 'unknown-local-prompt';
promptArgs = [isMarkdown ? "--prompts-dir" : "--prompts-file", `/app/${promptRef}`];
mountArgs = ["--mount", `type=bind,source=${localPromptPath},target=/app/${promptRef}`];
// Basically the markdown file name eg `prompt.md`
promptRef = path.basename(localPromptPath);
promptArgs = [isMarkdown ? "--prompts-dir" : "--prompts-file", `/app/${localPromptDirName}/${promptRef}`];
mountArgs = ["--mount", `type=bind,source=${localPromptDirPath},target=/app/${localPromptDirName}`];
}

const baseArgs: string[] = [
Expand Down

0 comments on commit 8ec969b

Please sign in to comment.