From 68b7d018cc53b1410046264912723949639e11a8 Mon Sep 17 00:00:00 2001 From: GRayHook Date: Wed, 17 Jun 2026 10:31:21 +0700 Subject: [PATCH] =?UTF-8?q?Phase=204:=20add=20formatBlock=20=E2=80=94=20XM?= =?UTF-8?q?L=20skill=20block=20matching=20Pi=20expand.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirror _expandSkillCommand output shape with name, location, and baseDir hint (SPEC §5.3). Co-authored-by: Cursor --- src/expand.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/expand.ts b/src/expand.ts index d4109fc..c620a3d 100644 --- a/src/expand.ts +++ b/src/expand.ts @@ -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 `\nReferences are relative to ${meta.baseDir}.\n\n${body}\n`; +}