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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zencommit",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "module": "./src/index.ts",
5
5
  "type": "module",
6
6
  "private": false,
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 url = new URL(`./prompts/${name}.md`, import.meta.url);
26
- const text = await Bun.file(url).text();
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
  };
@@ -0,0 +1,4 @@
1
+ declare module '*.md' {
2
+ const path: string;
3
+ export default path;
4
+ }