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:
@@ -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>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user