fix(skill): allow missing descriptions (#26391)
This commit is contained in:
@@ -27,7 +27,7 @@ const SKILL_PATTERN = "**/SKILL.md"
|
||||
|
||||
export const Info = Schema.Struct({
|
||||
name: Schema.String,
|
||||
description: Schema.String,
|
||||
description: Schema.optional(Schema.String),
|
||||
location: Schema.String,
|
||||
content: Schema.String,
|
||||
}).pipe(withStatics((s) => ({ zod: zod(s) })))
|
||||
@@ -93,7 +93,7 @@ const add = Effect.fnUntraced(function* (state: State, match: string, bus: Bus.I
|
||||
|
||||
if (!md) return
|
||||
|
||||
const parsed = z.object({ name: z.string(), description: z.string() }).safeParse(md.data)
|
||||
const parsed = z.object({ name: z.string(), description: z.string().optional() }).safeParse(md.data)
|
||||
if (!parsed.success) return
|
||||
|
||||
if (state.skills[parsed.data.name]) {
|
||||
@@ -269,12 +269,13 @@ export const defaultLayer = layer.pipe(
|
||||
)
|
||||
|
||||
export function fmt(list: Info[], opts: { verbose: boolean }) {
|
||||
if (list.length === 0) return "No skills are currently available."
|
||||
const described = list.filter((skill) => skill.description !== undefined)
|
||||
if (described.length === 0) return "No skills are currently available."
|
||||
if (opts.verbose) {
|
||||
return [
|
||||
"<available_skills>",
|
||||
...list
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
...described
|
||||
.toSorted((a, b) => a.name.localeCompare(b.name))
|
||||
.flatMap((skill) => [
|
||||
" <skill>",
|
||||
` <name>${skill.name}</name>`,
|
||||
@@ -288,7 +289,7 @@ export function fmt(list: Info[], opts: { verbose: boolean }) {
|
||||
|
||||
return [
|
||||
"## Available Skills",
|
||||
...list
|
||||
...described
|
||||
.toSorted((a, b) => a.name.localeCompare(b.name))
|
||||
.map((skill) => `- **${skill.name}**: ${skill.description}`),
|
||||
].join("\n")
|
||||
|
||||
Reference in New Issue
Block a user