@moskala/oneagent-templates 0.4.0 → 0.4.2
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/dist/index.d.ts +9 -0
- package/dist/index.js +42 -0
- package/package.json +10 -5
- package/src/index.ts +0 -60
- /package/{src → dist}/templates/default/instructions.md +0 -0
- /package/{src → dist}/templates/default/template.yml +0 -0
- /package/{src → dist}/templates/react/instructions.md +0 -0
- /package/{src → dist}/templates/react/template.yml +0 -0
- /package/{src → dist}/templates/react-native/instructions.md +0 -0
- /package/{src → dist}/templates/react-native/template.yml +0 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TemplatePlugin, type TemplateDefinition } from "@moskala/oneagent-core";
|
|
2
|
+
export type { TemplatePlugin, TemplateDefinition };
|
|
3
|
+
export declare function resolveBuiltinTemplate(name: string): Promise<TemplateDefinition | null>;
|
|
4
|
+
export declare const BUILTIN_TEMPLATE_NAMES: readonly string[];
|
|
5
|
+
export interface BuiltinTemplateMeta {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const BUILTIN_TEMPLATE_META: BuiltinTemplateMeta[];
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs/promises";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { parseTemplateYaml, resolveExtends } from "@moskala/oneagent-core";
|
|
6
|
+
var __dirname2 = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
var TEMPLATE_NAMES = ["default", "react", "react-native"];
|
|
8
|
+
async function loadTemplate(name) {
|
|
9
|
+
const templateDir = path.join(__dirname2, "templates", name);
|
|
10
|
+
const [yamlText, instructions] = await Promise.all([
|
|
11
|
+
fs.readFile(path.join(templateDir, "template.yml"), "utf-8"),
|
|
12
|
+
fs.readFile(path.join(templateDir, "instructions.md"), "utf-8")
|
|
13
|
+
]);
|
|
14
|
+
const parsed = parseTemplateYaml(yamlText, name);
|
|
15
|
+
const rulesDir = path.join(templateDir, "rules");
|
|
16
|
+
let rules = [];
|
|
17
|
+
try {
|
|
18
|
+
const ruleFiles = await fs.readdir(rulesDir);
|
|
19
|
+
rules = await Promise.all(ruleFiles.filter((f) => f.endsWith(".md")).map(async (f) => ({
|
|
20
|
+
name: path.basename(f, ".md"),
|
|
21
|
+
content: await fs.readFile(path.join(rulesDir, f), "utf-8")
|
|
22
|
+
})));
|
|
23
|
+
} catch {}
|
|
24
|
+
const base = { ...parsed, instructions, rules };
|
|
25
|
+
return resolveExtends(base, (n) => resolveBuiltinTemplate(n));
|
|
26
|
+
}
|
|
27
|
+
async function resolveBuiltinTemplate(name) {
|
|
28
|
+
if (!TEMPLATE_NAMES.includes(name))
|
|
29
|
+
return null;
|
|
30
|
+
return loadTemplate(name);
|
|
31
|
+
}
|
|
32
|
+
var BUILTIN_TEMPLATE_NAMES = TEMPLATE_NAMES;
|
|
33
|
+
var BUILTIN_TEMPLATE_META = [
|
|
34
|
+
{ name: "default", description: "General programming starter" },
|
|
35
|
+
{ name: "react", description: "React / Next.js project starter" },
|
|
36
|
+
{ name: "react-native", description: "React Native / Expo project starter" }
|
|
37
|
+
];
|
|
38
|
+
export {
|
|
39
|
+
resolveBuiltinTemplate,
|
|
40
|
+
BUILTIN_TEMPLATE_NAMES,
|
|
41
|
+
BUILTIN_TEMPLATE_META
|
|
42
|
+
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moskala/oneagent-templates",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Built-in templates for oneagent",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"module": "./
|
|
8
|
-
"main": "./
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
9
|
"exports": {
|
|
10
|
-
".":
|
|
10
|
+
".": {
|
|
11
|
+
"bun": "./src/index.ts",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
11
15
|
},
|
|
12
16
|
"files": [
|
|
13
|
-
"
|
|
17
|
+
"dist"
|
|
14
18
|
],
|
|
15
19
|
"scripts": {
|
|
20
|
+
"build": "bun ./scripts/build.ts",
|
|
16
21
|
"typecheck": "tsc --noEmit"
|
|
17
22
|
},
|
|
18
23
|
"dependencies": {
|
package/src/index.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs/promises";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { type TemplatePlugin, type TemplateDefinition, parseTemplateYaml, resolveExtends } from "@moskala/oneagent-core";
|
|
5
|
-
|
|
6
|
-
export type { TemplatePlugin, TemplateDefinition };
|
|
7
|
-
|
|
8
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
|
|
10
|
-
type BuiltinTemplateName = "default" | "react" | "react-native";
|
|
11
|
-
|
|
12
|
-
const TEMPLATE_NAMES: BuiltinTemplateName[] = ["default", "react", "react-native"];
|
|
13
|
-
|
|
14
|
-
async function loadTemplate(name: BuiltinTemplateName): Promise<TemplateDefinition> {
|
|
15
|
-
const templateDir = path.join(__dirname, "templates", name);
|
|
16
|
-
|
|
17
|
-
const [yamlText, instructions] = await Promise.all([
|
|
18
|
-
fs.readFile(path.join(templateDir, "template.yml"), "utf-8"),
|
|
19
|
-
fs.readFile(path.join(templateDir, "instructions.md"), "utf-8"),
|
|
20
|
-
]);
|
|
21
|
-
|
|
22
|
-
const parsed = parseTemplateYaml(yamlText, name);
|
|
23
|
-
|
|
24
|
-
const rulesDir = path.join(templateDir, "rules");
|
|
25
|
-
let rules: Array<{ name: string; content: string }> = [];
|
|
26
|
-
try {
|
|
27
|
-
const ruleFiles = await fs.readdir(rulesDir);
|
|
28
|
-
rules = await Promise.all(
|
|
29
|
-
ruleFiles
|
|
30
|
-
.filter((f) => f.endsWith(".md"))
|
|
31
|
-
.map(async (f) => ({
|
|
32
|
-
name: path.basename(f, ".md"),
|
|
33
|
-
content: await fs.readFile(path.join(rulesDir, f), "utf-8"),
|
|
34
|
-
})),
|
|
35
|
-
);
|
|
36
|
-
} catch {
|
|
37
|
-
// No rules directory — fine
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const base = { ...parsed, instructions, rules };
|
|
41
|
-
return resolveExtends(base, (n) => resolveBuiltinTemplate(n));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function resolveBuiltinTemplate(name: string): Promise<TemplateDefinition | null> {
|
|
45
|
-
if (!TEMPLATE_NAMES.includes(name as BuiltinTemplateName)) return null;
|
|
46
|
-
return loadTemplate(name as BuiltinTemplateName);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const BUILTIN_TEMPLATE_NAMES: readonly string[] = TEMPLATE_NAMES;
|
|
50
|
-
|
|
51
|
-
export interface BuiltinTemplateMeta {
|
|
52
|
-
name: string;
|
|
53
|
-
description: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const BUILTIN_TEMPLATE_META: BuiltinTemplateMeta[] = [
|
|
57
|
-
{ name: "default", description: "General programming starter" },
|
|
58
|
-
{ name: "react", description: "React / Next.js project starter" },
|
|
59
|
-
{ name: "react-native", description: "React Native / Expo project starter" },
|
|
60
|
-
];
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|