mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 03:01:56 +00:00
fix(coding-agent): ignore unknown skill frontmatter fields
This commit is contained in:
parent
fcfbc82ec2
commit
d0679dcfc0
5 changed files with 6 additions and 42 deletions
|
|
@ -5,20 +5,6 @@ import { CONFIG_DIR_NAME, getAgentDir } from "../config.js";
|
|||
import { parseFrontmatter } from "../utils/frontmatter.js";
|
||||
import type { ResourceDiagnostic } from "./diagnostics.js";
|
||||
|
||||
/**
|
||||
* Standard frontmatter fields per Agent Skills spec.
|
||||
* See: https://agentskills.io/specification#frontmatter-required
|
||||
*/
|
||||
const ALLOWED_FRONTMATTER_FIELDS = new Set([
|
||||
"name",
|
||||
"description",
|
||||
"license",
|
||||
"compatibility",
|
||||
"metadata",
|
||||
"allowed-tools",
|
||||
"disable-model-invocation",
|
||||
]);
|
||||
|
||||
/** Max name length per spec */
|
||||
const MAX_NAME_LENGTH = 64;
|
||||
|
||||
|
|
@ -91,19 +77,6 @@ function validateDescription(description: string | undefined): string[] {
|
|||
return errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for unknown frontmatter fields.
|
||||
*/
|
||||
function validateFrontmatterFields(keys: string[]): string[] {
|
||||
const errors: string[] = [];
|
||||
for (const key of keys) {
|
||||
if (!ALLOWED_FRONTMATTER_FIELDS.has(key)) {
|
||||
errors.push(`unknown frontmatter field "${key}"`);
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
export interface LoadSkillsFromDirOptions {
|
||||
/** Directory to scan for skills */
|
||||
dir: string;
|
||||
|
|
@ -197,16 +170,9 @@ function loadSkillFromFile(
|
|||
try {
|
||||
const rawContent = readFileSync(filePath, "utf-8");
|
||||
const { frontmatter } = parseFrontmatter<SkillFrontmatter>(rawContent);
|
||||
const allKeys = Object.keys(frontmatter);
|
||||
const skillDir = dirname(filePath);
|
||||
const parentDirName = basename(skillDir);
|
||||
|
||||
// Validate frontmatter fields
|
||||
const fieldErrors = validateFrontmatterFields(allKeys);
|
||||
for (const error of fieldErrors) {
|
||||
diagnostics.push({ type: "warning", message: error, path: filePath });
|
||||
}
|
||||
|
||||
// Validate description
|
||||
const descErrors = validateDescription(frontmatter.description);
|
||||
for (const error of descErrors) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue