@moskala/oneagent-templates 0.2.3 → 0.2.5
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/index.ts +7 -4
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs/promises";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
3
6
|
|
|
4
7
|
export interface TemplateDefinition {
|
|
5
8
|
name: string;
|
|
@@ -14,11 +17,11 @@ type BuiltinTemplateName = "default" | "react" | "react-native";
|
|
|
14
17
|
const TEMPLATE_NAMES: BuiltinTemplateName[] = ["default", "react", "react-native"];
|
|
15
18
|
|
|
16
19
|
async function loadTemplate(name: BuiltinTemplateName): Promise<TemplateDefinition> {
|
|
17
|
-
const templateDir = path.join(
|
|
20
|
+
const templateDir = path.join(__dirname, "templates", name);
|
|
18
21
|
|
|
19
22
|
const [yamlText, instructions] = await Promise.all([
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
fs.readFile(path.join(templateDir, "template.yml"), "utf-8"),
|
|
24
|
+
fs.readFile(path.join(templateDir, "instructions.md"), "utf-8"),
|
|
22
25
|
]);
|
|
23
26
|
|
|
24
27
|
// Minimal YAML parsing for our simple structure
|
|
@@ -44,7 +47,7 @@ async function loadTemplate(name: BuiltinTemplateName): Promise<TemplateDefiniti
|
|
|
44
47
|
.filter((f) => f.endsWith(".md"))
|
|
45
48
|
.map(async (f) => ({
|
|
46
49
|
name: path.basename(f, ".md"),
|
|
47
|
-
content: await
|
|
50
|
+
content: await fs.readFile(path.join(rulesDir, f), "utf-8"),
|
|
48
51
|
})),
|
|
49
52
|
);
|
|
50
53
|
} catch {
|