@@ -7,6 +7,7 @@ import type { ResourceDiagnostic } from "../../agents/sessions/diagnostics.js";
|
7 | 7 | import { createSyntheticSourceInfo, type SourceInfo } from "../../agents/sessions/source-info.js"; |
8 | 8 | import { parseFrontmatter } from "../../agents/utils/frontmatter.js"; |
9 | 9 | import { canonicalizePath } from "../../agents/utils/paths.js"; |
| 10 | +import { formatSkillsForPrompt as formatSkillContractForPrompt } from "./skill-contract.js"; |
10 | 11 | |
11 | 12 | /** Max name length per spec */ |
12 | 13 | const MAX_NAME_LENGTH = 64; |
@@ -343,39 +344,7 @@ function loadSkillFromFile(
|
343 | 344 | */ |
344 | 345 | export function formatSkillsForPrompt(skills: Skill[]): string { |
345 | 346 | const visibleSkills = skills.filter((s) => !s.disableModelInvocation); |
346 | | - |
347 | | -if (visibleSkills.length === 0) { |
348 | | -return ""; |
349 | | -} |
350 | | - |
351 | | -const lines = [ |
352 | | -"\n\nThe following skills provide specialized instructions for specific tasks.", |
353 | | -"Use the read tool to load a skill's file when the task matches its description.", |
354 | | -"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.", |
355 | | -"", |
356 | | -"<available_skills>", |
357 | | -]; |
358 | | - |
359 | | -for (const skill of visibleSkills) { |
360 | | -lines.push(" <skill>"); |
361 | | -lines.push(` <name>${escapeXml(skill.name)}</name>`); |
362 | | -lines.push(` <description>${escapeXml(skill.description)}</description>`); |
363 | | -lines.push(` <location>${escapeXml(skill.filePath)}</location>`); |
364 | | -lines.push(" </skill>"); |
365 | | -} |
366 | | - |
367 | | -lines.push("</available_skills>"); |
368 | | - |
369 | | -return lines.join("\n"); |
370 | | -} |
371 | | - |
372 | | -function escapeXml(str: string): string { |
373 | | -return str |
374 | | -.replace(/&/g, "&") |
375 | | -.replace(/</g, "<") |
376 | | -.replace(/>/g, ">") |
377 | | -.replace(/"/g, """) |
378 | | -.replace(/'/g, "'"); |
| 347 | +return formatSkillContractForPrompt(visibleSkills); |
379 | 348 | } |
380 | 349 | |
381 | 350 | export interface LoadSkillsOptions { |
|