fix: add strict YAML validation for plugin frontmatter (#399)

This commit is contained in:
Trevin Chow
2026-03-26 14:07:28 -07:00
committed by GitHub
parent e7921660ad
commit 0877b693ce
5 changed files with 73 additions and 9 deletions

View File

@@ -44,7 +44,7 @@ async function loadPersonalSkills(skillsDir: string): Promise<ClaudeSkill[]> {
let data: Record<string, unknown> = {}
try {
const raw = await fs.readFile(skillPath, "utf8")
data = parseFrontmatter(raw).data
data = parseFrontmatter(raw, skillPath).data
} catch {
// Keep syncing the skill even if frontmatter is malformed.
}
@@ -87,7 +87,7 @@ async function loadPersonalCommands(commandsDir: string): Promise<ClaudeCommand[
const commands: ClaudeCommand[] = []
for (const file of files) {
const raw = await fs.readFile(file, "utf8")
const { data, body } = parseFrontmatter(raw)
const { data, body } = parseFrontmatter(raw, file)
commands.push({
name: typeof data.name === "string" ? data.name : deriveCommandName(commandsDir, file),
description: data.description as string | undefined,

View File

@@ -60,7 +60,7 @@ async function loadAgents(agentsDirs: string[]): Promise<ClaudeAgent[]> {
const agents: ClaudeAgent[] = []
for (const file of files) {
const raw = await readText(file)
const { data, body } = parseFrontmatter(raw)
const { data, body } = parseFrontmatter(raw, file)
const name = (data.name as string) ?? path.basename(file, ".md")
agents.push({
name,
@@ -80,7 +80,7 @@ async function loadCommands(commandsDirs: string[]): Promise<ClaudeCommand[]> {
const commands: ClaudeCommand[] = []
for (const file of files) {
const raw = await readText(file)
const { data, body } = parseFrontmatter(raw)
const { data, body } = parseFrontmatter(raw, file)
const name = (data.name as string) ?? path.basename(file, ".md")
const allowedTools = parseAllowedTools(data["allowed-tools"])
const disableModelInvocation = data["disable-model-invocation"] === true ? true : undefined
@@ -104,7 +104,7 @@ async function loadSkills(skillsDirs: string[]): Promise<ClaudeSkill[]> {
const skills: ClaudeSkill[] = []
for (const file of skillFiles) {
const raw = await readText(file)
const { data } = parseFrontmatter(raw)
const { data } = parseFrontmatter(raw, file)
const name = (data.name as string) ?? path.basename(path.dirname(file))
const disableModelInvocation = data["disable-model-invocation"] === true ? true : undefined
skills.push({