zencommit 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/llm/prompt.ts +15 -2
- package/src/types/assets.d.ts +4 -0
package/package.json
CHANGED
package/src/llm/prompt.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { normalizePrompt, renderTemplate } from './prompt-template.js';
|
|
2
|
+
import baseTemplatePath from './prompts/base.md' with { type: 'file' };
|
|
3
|
+
import conventionalTemplatePath from './prompts/conventional.md' with { type: 'file' };
|
|
4
|
+
import gitmojiTemplatePath from './prompts/gitmoji.md' with { type: 'file' };
|
|
5
|
+
import systemTemplatePath from './prompts/system.md' with { type: 'file' };
|
|
2
6
|
|
|
3
7
|
export interface PromptInput {
|
|
4
8
|
style: 'conventional' | 'freeform';
|
|
@@ -16,14 +20,23 @@ export interface PromptOutput {
|
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
const templateCache = new Map<string, string>();
|
|
23
|
+
const templateFiles: Record<string, string> = {
|
|
24
|
+
base: baseTemplatePath,
|
|
25
|
+
conventional: conventionalTemplatePath,
|
|
26
|
+
gitmoji: gitmojiTemplatePath,
|
|
27
|
+
system: systemTemplatePath,
|
|
28
|
+
};
|
|
19
29
|
|
|
20
30
|
const loadTemplate = async (name: string): Promise<string> => {
|
|
21
31
|
const cached = templateCache.get(name);
|
|
22
32
|
if (cached) {
|
|
23
33
|
return cached;
|
|
24
34
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
35
|
+
const templatePath = templateFiles[name];
|
|
36
|
+
if (!templatePath) {
|
|
37
|
+
throw new Error(`Unknown prompt template: ${name}`);
|
|
38
|
+
}
|
|
39
|
+
const text = await Bun.file(templatePath).text();
|
|
27
40
|
templateCache.set(name, text);
|
|
28
41
|
return text;
|
|
29
42
|
};
|