frontmatter in skills files

This commit is contained in:
2026-02-18 01:23:22 +00:00
parent 030cf9fbd3
commit c2660cd125
16 changed files with 959 additions and 506 deletions
+5 -4
View File
@@ -11,9 +11,9 @@ type Frontmatter = {
triggers: TriggerConfig[];
};
export function parseFrontmatter(raw: string): { frontmatter: Frontmatter; body: string } {
export function parseFrontmatter(raw: string): { frontmatter: Frontmatter; body: string; rawYaml: string } {
const match = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
if (!match) return { frontmatter: { name: '', description: '', triggers: [] }, body: raw };
if (!match) return { frontmatter: { name: '', description: '', triggers: [] }, body: raw, rawYaml: '' };
const yaml = match[1]!;
const body = match[2]!;
@@ -38,7 +38,7 @@ export function parseFrontmatter(raw: string): { frontmatter: Frontmatter; body:
}
}
return { frontmatter: { name, description, triggers }, body };
return { frontmatter: { name, description, triggers }, body, rawYaml: yaml };
}
export async function readTaskDirs(dir: string): Promise<Map<string, string>> {
@@ -116,7 +116,7 @@ tasksRouter.get('/:name', async (ctx) => {
if (!resolved) return ctx.text('Not found', 404);
const raw = await Bun.file(resolved.filePath).text();
const { frontmatter, body } = parseFrontmatter(raw);
const { frontmatter, body, rawYaml } = parseFrontmatter(raw);
const chatMeta = join(dirname(resolved.filePath), 'chat', 'meta.json');
const chatSessionId = await Bun.file(chatMeta).json().then((m: { id: string }) => m.id).catch(() => null);
@@ -126,6 +126,7 @@ tasksRouter.get('/:name', async (ctx) => {
description: frontmatter.description,
scope: resolved.scope,
body,
rawFrontmatter: rawYaml,
filePath: resolved.filePath,
chatSessionId,
});