Phase 4: add formatBlock — XML skill block matching Pi expand.

Mirror _expandSkillCommand output shape with name, location, and baseDir hint (SPEC §5.3).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-17 10:31:21 +07:00
parent 584a8fa342
commit 68b7d018cc
+12
View File
@@ -1,8 +1,20 @@
import { readFileSync } from "node:fs";
import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
/** Skill fields needed to build the injected block (SPEC §5.3). */
export type SkillBlockMeta = {
name: string;
filePath: string;
baseDir: string;
};
/** mirror agent-session `_expandSkillCommand` — SKILL.md body without YAML frontmatter (SPEC §5.3, §10). */
export function readSkillBody(filePath: string): string {
const content = readFileSync(filePath, "utf-8");
return stripFrontmatter(content).trim();
}
/** mirror agent-session `_expandSkillCommand` — XML skill block with baseDir hint (SPEC §5.3). */
export function formatBlock(meta: SkillBlockMeta, body: string): string {
return `<skill name="${meta.name}" location="${meta.filePath}">\nReferences are relative to ${meta.baseDir}.\n\n${body}\n</skill>`;
}