mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 19:04:23 +00:00
feat(agent): migrate to pi-agent-core harness and restore robust frontmatter parsing
This commit is contained in:
@@ -4,9 +4,9 @@ import { s3Service } from '@/services/s3/s3'
|
||||
import AdmZip from 'adm-zip'
|
||||
import * as crypto from 'crypto'
|
||||
import { ulid } from 'ulid'
|
||||
import { parse } from 'yaml'
|
||||
import { parseFrontmatter } from '@/utils/frontmatter'
|
||||
|
||||
interface SkillFrontmatter {
|
||||
interface SkillFrontmatter extends Record<string, unknown> {
|
||||
name?: string
|
||||
description?: string
|
||||
}
|
||||
@@ -258,15 +258,7 @@ export class SkillService {
|
||||
}
|
||||
|
||||
private parseSkillMd(content: string): { name: string; description: string } {
|
||||
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n([\s\S]*))?$/)
|
||||
let frontmatter: SkillFrontmatter = {}
|
||||
if (match) {
|
||||
try {
|
||||
frontmatter = parse(match[1])
|
||||
} catch (e) {
|
||||
console.error('Failed to parse skill frontmatter', e)
|
||||
}
|
||||
}
|
||||
const { frontmatter } = parseFrontmatter<SkillFrontmatter>(content)
|
||||
const name = frontmatter.name || 'Unnamed Skill'
|
||||
const description = frontmatter.description || ''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user