/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/core/src/config/markdown.ts
36 строк
1 KB
Dax
feat(core): add skill registry and file agent loading (#30617)
03 июн 2026, 23:58
Не верифицирован
03 июн 2026, 23:58
889e0f9
Код
Авторство
О чём код?
export * as ConfigMarkdown from "./markdown" import matter from "gray-matter" export function parse(content: string) { try { return matter(content) } catch { return matter(sanitize(content)) } } export function parseOption(content: string) { try { return parse(content) } catch { return undefined } } // Other coding agents accept unquoted colons in frontmatter values. Retry // those values as YAML block scalars so existing config files keep working. export function sanitize(content: string) { const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/) if (!match) return content const frontmatter = match[1] const result = frontmatter.split(/\r?\n/).flatMap((line) => { if (line.trim().startsWith("#") || line.trim() === "" || /^\s+/.test(line)) return [line] const entry = line.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*:\s*(.*)$/) if (!entry) return [line] const value = entry[2].trim() if (value === "" || value === ">" || value === "|" || value.startsWith('"') || value.startsWith("'")) return [line] if (!value.includes(":")) return [line] return [`${entry[1]}: |-`, ` ${value}`] }) return content.replace(frontmatter, () => result.join("\n")) }