forked from wrtnlabs/agentica
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt.ts
More file actions
34 lines (31 loc) · 920 Bytes
/
prompt.ts
File metadata and controls
34 lines (31 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import fs from "fs";
const DIRECTORY = `${__dirname}/../prompts`;
const main = async (): Promise<void> => {
const directory: string[] = await fs.promises.readdir(DIRECTORY);
const record: Record<string, string> = {};
for (const file of directory) {
if (file.endsWith(".md") === false) continue;
const content: string = await fs.promises.readFile(
`${DIRECTORY}/${file}`,
"utf8",
);
record[file.substring(0, file.length - 3)] = content
.split("\r\n")
.join("\n")
.trim();
}
await fs.promises.writeFile(
`${__dirname}/../src/internal/WrtnAgentSystemPrompt.ts`,
[
`export namespace WrtnAgentSystemPrompt {`,
...Object.entries(record).map(
([key, value]) =>
` export const ${key.toUpperCase()} =\n ${JSON.stringify(value)};`,
),
`}`,
"",
].join("\n"),
"utf8",
);
};
main().catch(console.error);